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
Hi,
Firstly, this looks like a great plugin! Just what I need :)
But, I'm having problems getting the values when it's in a single item mode. I've followed the documentation. I'm using a partial macros
@inherits Umbraco.Web.Macros.PartialViewMacroPage @{ var rightbanner = CurrentPage.GetPropertyValue<IPublishedContent>("rightBanner"); var h4 = rightbanner.GetPropertyValue("h4"); }
rightbanner retrieves a value as a Our.Umbraco.NestedContent.Models.DetachedPublishedContent
but the GetPropertyValue function doesn't get my h4 content.
Here's a screenshot when debugging. I can see the value, I just don't know how to drill down to it.
Any help would be appreciated.
Many Thanks
Tim
Hi Tim,
When you step on to the next line, does the h4 variable have any value?
h4
As looking at the debugging data, it should return a value.
If it doesn't return any value, then you could try an alternative approach:
var h4 = rightbanner.GetProperty("h4").Value;
Cheers, - Lee
Hi Lee
It doesn't return a value. I get the following error.
Additional information: 'Umbraco.Web.Models.PublishedContentBase' does not contain a definition for 'GetPropertyValue'
But I've found the solution:
@inherits Umbraco.Web.Macros.PartialViewMacroPage @{ IPublishedContent rightbanner = CurrentPage.GetPropertyValue<IPublishedContent>("rightBanner"); var h4 = rightbanner.GetPropertyValue("h4"); }
I changed the var to IPublishedContent and it worked. Not sure if it's because I'm using a Partial Macro instead of a Partial View.
Thanks
Glad that you've got it working!
The error for "'X' does not contain a definition for 'GetPropertyValue'" usually means that the View/Partial is missing a namespace reference. Try adding this to the top of your partial:
@using Umbraco.Web;
Hi Lee,
Just tried putting in the namespace, it didn't work.
Seems like it really wants the variable to be defined as a IPublishedContent instead of a var.
Anyhow it's working and it's perfect for what I needed it for :)
OK, no worries - glad it's working now! :-)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Single Item mode, getting values
Hi,
Firstly, this looks like a great plugin! Just what I need :)
But, I'm having problems getting the values when it's in a single item mode. I've followed the documentation. I'm using a partial macros
rightbanner retrieves a value as a Our.Umbraco.NestedContent.Models.DetachedPublishedContent
but the GetPropertyValue function doesn't get my h4 content.
Here's a screenshot when debugging. I can see the value, I just don't know how to drill down to it.
Any help would be appreciated.
Many Thanks
Tim
Hi Tim,
When you step on to the next line, does the
h4
variable have any value?As looking at the debugging data, it should return a value.
If it doesn't return any value, then you could try an alternative approach:
Cheers,
- Lee
Hi Lee
It doesn't return a value. I get the following error.
Additional information: 'Umbraco.Web.Models.PublishedContentBase' does not contain a definition for 'GetPropertyValue'
But I've found the solution:
I changed the var to IPublishedContent and it worked. Not sure if it's because I'm using a Partial Macro instead of a Partial View.
Thanks
Tim
Hi Tim,
Glad that you've got it working!
The error for "'X' does not contain a definition for 'GetPropertyValue'" usually means that the View/Partial is missing a namespace reference. Try adding this to the top of your partial:
Cheers,
- Lee
Hi Lee,
Just tried putting in the namespace, it didn't work.
Seems like it really wants the variable to be defined as a IPublishedContent instead of a var.
Anyhow it's working and it's perfect for what I needed it for :)
OK, no worries - glad it's working now! :-)
is working on a reply...