Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I need to put some facebook meta data in the head section of a page. The data lives inside of a razor script.
I have a contentplaceholder called "cphScripts" that lives in the master page that the macroscript (razor) lives in.
Is there a way to access it from the razor script? Is there another way to get my data into the head section?
Hi Nate,
You can simply to this by adding an Inline Razor Macro in your template within the ContentPlaceHolder.
<asp:Content ContetenPlaceHolderId="cphScripts" runat="server"> <umbraco:Macro runat="server" language="cshtml">@{} </umbraco:Macro></asp:Content>
I just marked you as an answer but I think we have it backwards.
I have a CSHTML file and I want to add the asp:Content section.
I think you're showing the above that I have a regular template page and you add the razor to that.
Yes am in a regulare template here. What were you trying to achive ?
My structure is like this.
Template 1 -> Template 2 -> Template 3 -> Macro (razor .cshtml file)
In side the razor file, I want to access that cphScripts content.
So my file is like the one below, but the <asp:content is not recongnized.
Thanks man!
@inherits umbraco.MacroEngines.DynamicNodeContext @{
//Some code here
}
<asp:content ContentPlaceHolderId="cphScripts" runat="server"> <meta property="fb:app_id" content="123456" /> <meta property="og:type" content="fitness.bikes" /> <meta property="og:url" content="@url" /> <meta property="og:title" content="@careerWorkout.WorkoutName" /> <meta property="og:description" content="@workoutNotesText /> <meta property="og:image" content="@careerWorkout.PictureLocation" /> </asp:content>
<p>There's some stuff in here</p>
So you want to do something like this if am not mistaken here
<asp:Content ContetenPlaceHolderId="cphScripts"runat="server"> <umbraco:Macrorunat="server"language="cshtml">@{ if(@Model.HasValue("careerWorkout")){ <metaproperty="og:title"content="@Model.careerWorkout"/> }} </umbraco:Macro></asp:Content>
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Access <head> section from razor script?
I need to put some facebook meta data in the head section of a page. The data lives inside of a razor script.
I have a contentplaceholder called "cphScripts" that lives in the master page that the macroscript (razor) lives in.
Is there a way to access it from the razor script? Is there another way to get my data into the head section?
Hi Nate,
You can simply to this by adding an Inline Razor Macro in your template within the ContentPlaceHolder.
I just marked you as an answer but I think we have it backwards.
I have a CSHTML file and I want to add the asp:Content section.
I think you're showing the above that I have a regular template page and you add the razor to that.
Hi Nate,
Yes am in a regulare template here. What were you trying to achive ?
My structure is like this.
Template 1 -> Template 2 -> Template 3 -> Macro (razor .cshtml file)
In side the razor file, I want to access that cphScripts content.
So my file is like the one below, but the <asp:content is not recongnized.
Thanks man!
//Some code here
}
<p>There's some stuff in here</p>
So you want to do something like this if am not mistaken here
is working on a reply...