We're working on update our site from 6.2.4 version to 7.3.7
We've tried to retrieve and show a property of a IPublishedContent object. Unfortunatly, GetPropertyValue method returns nothing (empty string or null).
Here is how we trying to use it:
// This line returns valid array (in our case it contains just one item, but can more)
var newsItems = Model.Content.Descendants("NewsItem").Where(ni => !ni.GetPropertyValue<bool>("hideOnNewsPage")).OrderByDescending(ni => ni.GetPropertyValue<string>("newsEntryDate")).ToList();
@foreach (var newsItem in newsItems)
{
var link = newsItem.GetPropertyValue<string>("newsEntryExternalLink");
counter++;
<div class="col-sm-6" style="@(counter % 2 == 0 ? "clear:right;" : "clear:left;")">
//Next two lines return "True", so we can know that a property really exist
<span>@newsItem.HasProperty("newsEntryDate").ToString()</span>
<span>@newsItem.HasValue("newsEntryDate").ToString()</span>
//Next line returns "False", so it means that a value exist
<span>@newsItem.IsNull("newsEntryDate").ToString()</span>
<div class="content-box icon-top-aligned-text">
<div class="press-release-icon">
//Next line represents just empty <em></em> element on the HTML page. Same for all other usages of GetPropertyValue method <em>@{newsItem.GetPropertyValue("newsEntryDate").ToString();}</em>
</div>
</div>
</div>
}
NOTE: HasProperty and HasValue mehods return "True" value, so we'd
expect that it will return something else than empty string.
Also we've tried to use "newsItem.newsEntryDate", however it throws an exception that the Property is undefined.
A nice check is to look in the "/App_Data/umbraco.config" file - there you can see the if the properties you're trying to access exist and have values.
Like Alessandro says, a republish updates this file.
IPublishedContent Property Access
Hi there,
We're working on update our site from 6.2.4 version to 7.3.7
We've tried to retrieve and show a property of a IPublishedContent object. Unfortunatly, GetPropertyValue method returns nothing (empty string or null).
Here is how we trying to use it:
Also we've tried to use "newsItem.newsEntryDate", however it throws an exception that the Property is undefined.
Have you tried to rebuild the cache by republishing the site?
A nice check is to look in the "/App_Data/umbraco.config" file - there you can see the if the properties you're trying to access exist and have values.
Like Alessandro says, a republish updates this file.
Hi guys, thanks for your answers.
Actually, "/App_Data/umbraco.config" file contains correct data about the object. So I'd expect that is should be displayed.
I've tried to uppublish and publish again, but it's not working for me.
Do you have any ideas why it can happen?
What happens when you try
newsItem.GetPropertyValue<string>("newsEntryDate")
Empty as well. Same for the:
is working on a reply...