On the Content Section, the User has a Checkbox where he can check if he wants to have the Meta Robots String included in the Output page, else it gets the "robots No Follow" html string in the head section.
<meta name="robots" content="index, follow">
The Propertie Alias = metaRobotsFollow
I added this code in the masterpagetemplate, but it dont work :(
Not knowing what kind of system you're doing, wouldn't it be better to have it the other way around (check to exclude rather than include). Or is it sensitive data?
Aslo, you can mark you own reply as the solution, which would help others in the futere.
My first macro :)
Hy :)
I have a checkbox property for the user.
On the Content Section, the User has a Checkbox where he can check if he wants to have the Meta Robots String included in the Output page, else it gets the "robots No Follow" html string in the head section.
<meta name="robots" content="index, follow">
The Propertie Alias = metaRobotsFollow
I added this code in the masterpagetemplate, but it dont work :(
<umbraco:Macro runat="server" language="cshtml">
@using umbraco.MacroEngines
@inherits umbraco.MacroEngines.DynamicNodeContext
@{
if (model.metaRobotsFollow.Value == '1')
{
<meta name="robots" content="index, follow">
}
else
{
<meta name="robots" content="index, nofollow">
}
}
</umbraco:Macro>
Got it working now :) after reading a few discussions online, i made this one and it works perfectly :)
@{
if (@CurrentModel.HasProperty("metaRobotsFollow"))
{
string value = CurrentModel.GetProperty("metaRobotsFollow").Value;
string robotsfollow = "";
if (value == "1")
{
robotsfollow = "<meta name='robots' content='index, follow' />";
}
else
{
robotsfollow = "<meta name='robots' content='index, nofollow' />";
}
@Html.Raw(robotsfollow);
}
}
Hi Sacha
Not knowing what kind of system you're doing, wouldn't it be better to have it the other way around (check to exclude rather than include). Or is it sensitive data?
Aslo, you can mark you own reply as the solution, which would help others in the futere.
Have a nice day.
is working on a reply...