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
Using Umbraco version 7.5.4, I've created a separate Global settings node outside of the main structure see image below, which just contains global info for the site. When I add the corresponding Umbraco field within my page templates the info doesn't render, any clue where I am going wrong.
As always much appreciated in with any help.
i would guess it because you are not finding the global settings node before you ask for the values.
in your template you will first need to find the global settings node ?
something like :
var settings = Umbraco.TypedContentSingleAtXPath("\\globalSettings");
var twitterUrl = settings.GetPropertyValue<string>("twitterUrl")
might work . assuming your global site settings node doctype is called globalSettings
i usually put something this in a helper class, then you can call it without doing the lookup.*
public static class GlobalSettingsExtensions
public static IPublishedContent GlobalSettings(this UmbracoHelper umbraco)
would (when namespace is included in the razor) let you do something like:
* error checking not included
nice tip about using an extension on the UmbracoHelper class for returning a root node!
Thanks for this helper class.
Needed to change a few things, but then it worked great...
BTW ... the changes I made:
changed backward slashes to forward slashes => ("//globalSettings");
added round brackets to GlobalSettings => @Umbraco.GlobalSettings().GetPropertyValue("twitterUrl")
Thanks for your help, your solution worked great.
Thanks for posting this. I need to the same thing!
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted