Add markup to <head> by macro in article/body (v4.71)
Hi all,
I'm having a difficult time figuring this one out.
Here's the scenario:
I have a macro which lists x items in a pagelist (added by the editor)
It also supports/adds pagination ("< Prev page 1 2 3 ... Next Page >")
We now wish to add <link rel="prev/next" href="[url]"> tags in <head> based on pagination logic in the macro script.
Templates are masterpages/webform based.
Could I somehow add an old-school control as global container (<asp:Literal id="litHeadMarkup".../>) which I can access and modify from a razor macro? Or maybe another (preferable nicer) alternative?
Any thoughts are highly appreciated. Thanks a bunch, Dennis
Thanks for your response. I've added the runat=server to the head but I don't seem to access it from the razor. Maybe I do something wrong. Would you mind provide some brief example code for the razor script accessing the <head runat="server" id="MasterPageHeader">?
So what are you saying is to set a ViewBag.NextHref value in the Macro Partial and get the Value of this Viewbag in the head section in the MasterPage?
Add markup to <head> by macro in article/body (v4.71)
Hi all,
I'm having a difficult time figuring this one out.
Here's the scenario:
Could I somehow add an old-school control as global container (<asp:Literal id="litHeadMarkup".../>) which I can access and modify from a razor macro? Or maybe another (preferable nicer) alternative?
Any thoughts are highly appreciated.
Thanks a bunch,
Dennis
Dennis,
You could do head runat=server then in the razor access that and add new literal control with the link?
Regards
Ismail
Ismail,
Thanks for your response. I've added the runat=server to the head but I don't seem to access it from the razor. Maybe I do something wrong. Would you mind provide some brief example code for the razor script accessing the
<head runat="server" id="MasterPageHeader">
?I got it, at last!
My solution:
Added a plain Literal-control to my root masterpage (and removed runat=server from the
<head>
):I accessed the control from my razor script by doing:
Hope it helps anybody else looking for this.
And thanks for your inputs!
Hi all,
Do you have any idea how can I achieve this through MVC razor, since I am not using web forms?
I want that in a macro, I set the canonical url next/prev in the head section pls.
Thank you.
Kind Regards
@Simon Wouldn't you be able to use the ViewBag for that?
Hi Morten,
How can I achive this, using ViewBag? Can you please give me an example?
Thank you very much
Sure... It's basically ViewBag 101:
In your controller action
In your _Layout file
Hi Morten,
Preferabbly I do not want to modify the umbraco controllers.
Moreover, I want to set the <link> in the head section from a Macro partial, from where the pagination logic is located.
Any ideas pls?
Thank you.
What have you tried so far?
Have you tried setting the ViewBag.NextHref from your MacroPartial?
So what are you saying is to set a ViewBag.NextHref value in the Macro Partial and get the Value of this Viewbag in the head section in the MasterPage?
Thank you.
Yes.
No success.
Nothing is being shown in the head.
is working on a reply...