Render related links contained in Archetype 'section'
Hi folks.
I'm having trouble rendering a Related Links picker that's found in an Archetype section.
To further explain I've got a Archetype with three properties, 2 textstrings and a related links picker. I can get the string values no problem but I cannot get the related links.
What I've got so far is:
var linksNode = new umbraco.NodeFactory.Node(dNode.Id);
var links = JsonConvert.DeserializeObject<ArchetypeModel>(linksNode.GetProperty("drawerSection").Value);
foreach (var link in links)
{
<p>@link.GetValue("drawerColumns")</p> //displays fine
<p>@link.GetValue("drawerTitle")</p> //displays fine
}
If I use @link.Getvalue("drawerLinks") I see an enormous string that contained all of the related link data but try as I might I can't get 'inside' it to loop through all of the links.
Render related links contained in Archetype 'section'
Hi folks.
I'm having trouble rendering a Related Links picker that's found in an Archetype section.
To further explain I've got a Archetype with three properties, 2 textstrings and a related links picker. I can get the string values no problem but I cannot get the related links.
What I've got so far is:
If I use @link.Getvalue("drawerLinks") I see an enormous string that contained all of the related link data but try as I might I can't get 'inside' it to loop through all of the links.
Any advice would be greatly received.
Thanks, C
Hi Craig
You have to parse related links json for rendering it, try this code
Hi Alex,
Fantastic! I'm getting some errors on the linkUrl and linkTarget but I think that is down to the UDI / ID change in Umbraco.
Thanks again, Craig
Hi Craig
What error? Lets have a look together
Hiya,
The error is:
'item.Value
System.FormatException: 'Input string was not in a correct format.'
item = {{ "caption": "Anti money Laundering", "link": "umb://document/a2fb93c35b6342548332aa130ea01ac0", "newWindow": false, "internal": "umb://document/a2fb93c35b6342548332aa130ea01ac0", "edit": false, "isInternal": true, "internalName": "UK"...
These are the values contained within the item
I'm resuming that I need to convert this UDI into an ID in order to be able to use the NiceUrl.
Thanks, Craig
Hi Craig
Try this line:
Good work!
Just had to change the external link clause as obviously Umbraco doesn't know what www.imdb.com is!
Thanks for your time and assistance :)
Thanks, C
is working on a reply...