Accessing a property on another page? Umbraco v7.6
I'm trying to access a property on another page ... specifically from a Related Links property type. I can get get my code to see an existing property value on the page, but I'm having trouble accessing the property fields in a related links property type.
Here's what I'm working with so far:
else if (childPage.GetPropertyValue("anchorLinkOption")==true)
{
In this first statement, the "anchorLinkOption" property value is accessed and triggers this next part of the conditional statment ... this is working as expected ... but this next part ...
var typedRelatedLinksConverted = Model.Content.GetPropertyValue<RelatedLinks>("rLinksTarget");
if (typedRelatedLinksConverted.Any())
{
... is returning a "null value" (currently) and I'm pretty sure it's only looking at the currently loaded page and not the childPage. So, I'm having trouble rewriting this part of the statement to access the same childpage that had the "anchorLinkOption" property value to access the Related Links property type:
Model.Content.GetPropertyValue
Any insight or references you can point me to would be greatly appreciated.
var typedRelatedLinksConverte1d = Model.Content.GetPropertyValue<RelatedLinks>("rLinksTarget");
foreach (var child in Model.Content.Children)
{
var typedRelatedLinksConverted2 = child.GetPropertyValue<RelatedLinks>("rLinksTarget");
if (typedRelatedLinksConverted2.Any())
{
}
}
Hey Alex ... this was a side thread I had created to resolve the same issue as the dynamic nav. The code block you shared here didn't work for me, but the code you posted in my other thread worked perfectly!
Thanks again!
UPDATE: Here's the link to the completed code that applies Alex's solution for anyone else looking to resolve this:
Accessing a property on another page? Umbraco v7.6
I'm trying to access a property on another page ... specifically from a Related Links property type. I can get get my code to see an existing property value on the page, but I'm having trouble accessing the property fields in a related links property type.
Here's what I'm working with so far:
In this first statement, the "anchorLinkOption" property value is accessed and triggers this next part of the conditional statment ... this is working as expected ... but this next part ...
... is returning a "null value" (currently) and I'm pretty sure it's only looking at the currently loaded page and not the childPage. So, I'm having trouble rewriting this part of the statement to access the same childpage that had the "anchorLinkOption" property value to access the Related Links property type:
Any insight or references you can point me to would be greatly appreciated.
Hi Brett
Try this code:
Hey Alex ... this was a side thread I had created to resolve the same issue as the dynamic nav. The code block you shared here didn't work for me, but the code you posted in my other thread worked perfectly!
Thanks again!
UPDATE: Here's the link to the completed code that applies Alex's solution for anyone else looking to resolve this:
How to add anchor links to dynamic navigation?
https://our.umbraco.org/forum/using-umbraco-and-getting-started/85729-how-to-add-anchor-links-to-dynamic-navigation
Hi Brett
Glad that we solved this issue. Have a great day!
Alex
is working on a reply...