MultiNodeTreepicker - displaying links to subpages in a footer
Hi guys!
Merry Christmas!
I have a small problem atm. I am trying to display a list of links, which has been selected from a MultiNode Treepicker.
The content is tied up to my master file, so i can access it from all over my website, but i can't get the MultiNode Treepicker to show med the correct result. My code looks like this:
I had a look at your code. Could you please try using this code below.
@{
var page = Model.Content.AncestorOrSelf(1);
if (page.HasValue("nyttigeLinks"))
{
var bannerListValue = page.GetPropertyValue<string>("nyttigeLinks");
var bannerList = bannerListValue.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse);
var bannerCollection = Umbraco.TypedContent(bannerList).Where(x => x != null);
foreach (var item in bannerCollection)
{
<p>@item.Name</p>
}
}
}
I would recommend you not to code against Id´s in Umbraco if possible for you, the reason for this is that the Id can change if people are deleting the node and re-created it then it will get another id.
What I have done is using the var page = Model.Content.AncestorOrSelf(1);which means that you to the the top of your content tree which would be the homepage node.
It can be necessary for you to change this depending on how your content tree structure looks like.
Thank you for your every helping nature and your repsonse!
When i try to use the Model.Content.AncestorOrSelf(1); i get this compliation error:
CS1061: 'Umbraco.Core.Models.IPublishedContent' does not contain a
definition for 'Content' and no extension method 'Content' accepting a
first argument of type 'Umbraco.Core.Models.IPublishedContent' could
be found (are you missing a using directive or an assembly reference?)
And when i dont use it i get this error:
CS1976: Cannot use 'Parse' as an argument to a dynamically dispatched operation because it is a method group. Did you intend to invoke the method?
MultiNodeTreepicker - displaying links to subpages in a footer
Hi guys!
Merry Christmas!
I have a small problem atm. I am trying to display a list of links, which has been selected from a MultiNode Treepicker.
The content is tied up to my master file, so i can access it from all over my website, but i can't get the MultiNode Treepicker to show med the correct result. My code looks like this:
I want it to display my list of "nyttige links" in the "Nyttige Links" section.
Can anyone help me?
Hi Magnus,
I had a look at your code. Could you please try using this code below.
I would recommend you not to code against Id´s in Umbraco if possible for you, the reason for this is that the Id can change if people are deleting the node and re-created it then it will get another id.
What I have done is using the
var page = Model.Content.AncestorOrSelf(1);
which means that you to the the top of your content tree which would be the homepage node.It can be necessary for you to change this depending on how your content tree structure looks like.
Hope this helps,
/Dennis
Hi Dennis,
Thank you for your every helping nature and your repsonse!
When i try to use the Model.Content.AncestorOrSelf(1); i get this compliation error:
And when i dont use it i get this error:
Can you help with any of this?
Merry Christmas by the way! :)
/Magnus
Hi Magnus,
Merry Christmas to you too. Could you please try this code below and see if it works for you.
Hope this helps,
/Dennis
Hey Dennis,
Now i am on the other side of christmas and new years.
I can get this to work - however, what i need this list to do, is to work as links. Would that be possible?
Kind regards, Magnus
Hi Magnus,
Hope you had a great Christmas and new year.
Sure, then you need to do like this. Then you should get links with the url to the page.
Hope this helps,
/Dennis
Thank you very much Dennis!
It works now :)
Kind regards, Magnus
is working on a reply...