Property shown in umbraco.config but GetPropertyValue(propertyAlias) returns null
I started work on my U7 site this morning and built the code, after which my Nav stopped working.
My nav is loaded dynamically by looking for Umbraco properties. 'navText' tells it what to display on the menu and 'navSource' tells it which menu the content should feature on (for multiple levels). This was working fine on Friday. After a rebuild this morning, not so much.
The nav is built using the following code (adjusted for additional debugging verboseness...
public INavigation Build(IPublishedContent currentContent, string navSource)
{
var possiblyNavigableNodes = new List<IPublishedContent> {_contentRepo.RootAncestor};
foreach (var level2Node in _contentRepo.RootAncestor.Children)
{
possiblyNavigableNodes.Add(level2Node);
possiblyNavigableNodes.AddRange(level2Node.Children);
}
var items = new List<NavigationItem>();
foreach (IPublishedContent item in possiblyNavigableNodes)
{
if (item.HasValue(CommonProperties.NavText) && item.HasValue(CommonProperties.NavSource) && (item.GetPropertyValue(CommonProperties.NavSource).ToString().Contains(navSource))) items.Add(new NavigationItem(item));
}
var model = new Navigation
{
Home = new NavigationItem(_contentRepo.RootAncestor),
CurrentItem = new NavigationItem(currentContent.NextNavigableAncestor(navSource)),
NavigationItems = new ReadOnlyCollection<NavigationItem>(items)
};
return model;
}
The code itself generally works except for the fact that...
item.HasValue(CommonProperties.NavSource)
returns false and...
item.GetPropertyValue(CommonProperties.NavSource)
is now returning null.
This seems to be a content issue of some sort. The property IS present in the backend and the data looks fine.
I have tried...
Clearing out the temp files
Deleting umbraco.config
Rebuilding the code
Republishing the entire site and all the sub nodes
Stepping through the code to replace the constants with fixed values ('navSource' and 'NavSource' both tested)
I'm a bit at a loss now - can anyone offer any more suggestions?
MORE INFO: I can now confirm that the 'navSource' data IS listed in the generated umbraco.config file, but for some reason is not being picked up by code. Here's some sample XML...
<SegmentPage id="1124" parentID="1047" level="2" creatorID="0" sortOrder="1" createDate="2013-01-17T12:57:03" updateDate="2015-01-19T10:42:00" nodeName="How We Work" urlName="how-we-work" path="-1,1047,1124" isDoc="" nodeType="1068" creatorName="admin" writerName="admin" writerID="0" template="1067" nodeTypeAlias="SegmentPage">
<navText><![CDATA[How We Work]]></navText>
<primaryHeader><![CDATA[Agile Processes]]></primaryHeader>
<navSource><![CDATA[Main]]></navSource>
<bodyText><![CDATA[<p>All our managed work is undertaken using agile approaches from our development work right the way up to our communications with our clients. Agile methodologies actively encourage change and adopting 'what works for you' and we will utilise the most appropriate mix of SCRUM and Kanban principles to maximise quality, communication ond return on investments for our clients. See the section below for more information on what Agile is.</p>
<p>All our internal projects are currently managed using a cross-project Kanban variant which we have evolved over the last 12 months to optimise our effectiveness and maximise our ability to deliver consistently and provide realistic timescales.</p>
<h3>Transparency</h3>
<p>A highly functional agile approach requires trust and communication regularly between stakeholders and those delivering. In order to facilitate this we operate a completely transparent costing and charging policy to our clients with individual resources applied to projects charged out on a given rate and subcontracted costs passed on directly so that our clients always know exactly what they are paying for.</p>
<h3>Customisation</h3>
<p>This transparency allows us to fine tune the service that we offer to your business to provide just the resourcing and support that you need to ensure that your project is delivered to a high standard.</p>]]></bodyText>
<featuredArticle>1089</featuredArticle>
</SegmentPage>
I don't know if this helps any, but if I compare the *.config file in App_Data/preview with umbraco.config then the navSource nodes were MISSING.
I deleted this file and now it seems to be working again. For some reason it seems that it was using the preview config instead of the main umbraco.config.
re: Preview mode - when you use the preview mode, a cookie will be set (I think it's UMB_PREVIEW if I recall correctly). The core checks for that cookie when getting the XML content (either from 'umbraco.config' or the 'App_Data/preview' folder).
Once the cookie is cleared (or the GUID filename of the preview XML is deleted), the core will come out of preview mode.
As for why it was missing the <navSource> elements - I'm not sure - haven't seen that before.
Property shown in umbraco.config but GetPropertyValue(propertyAlias) returns null
I started work on my U7 site this morning and built the code, after which my Nav stopped working.
My nav is loaded dynamically by looking for Umbraco properties. 'navText' tells it what to display on the menu and 'navSource' tells it which menu the content should feature on (for multiple levels). This was working fine on Friday. After a rebuild this morning, not so much.
The nav is built using the following code (adjusted for additional debugging verboseness...
The code itself generally works except for the fact that...
returns false and...
is now returning null.
This seems to be a content issue of some sort. The property IS present in the backend and the data looks fine.
I have tried...
I'm a bit at a loss now - can anyone offer any more suggestions?
MORE INFO: I can now confirm that the 'navSource' data IS listed in the generated umbraco.config file, but for some reason is not being picked up by code. Here's some sample XML...
I don't know if this helps any, but if I compare the *.config file in App_Data/preview with umbraco.config then the navSource nodes were MISSING.
I deleted this file and now it seems to be working again. For some reason it seems that it was using the preview config instead of the main umbraco.config.
Any idea why?
Hi Keith,
re: Preview mode - when you use the preview mode, a cookie will be set (I think it's
UMB_PREVIEW
if I recall correctly). The core checks for that cookie when getting the XML content (either from 'umbraco.config' or the 'App_Data/preview' folder).Once the cookie is cleared (or the GUID filename of the preview XML is deleted), the core will come out of preview mode.
As for why it was missing the
<navSource>
elements - I'm not sure - haven't seen that before.Cheers,
- Lee
I blame my brief foray into testing. Now everything that can go wrong does! /me sighs...
is working on a reply...