After adding a property of this type to a page you will see in edit mode this:
And with a few links added property looks like this:
This is first significant change comparing to old Multipage property (MP) -- list of all links is visible on the page. With old MP it was necessary to click on the button to get a popup with a list of links. That is a good change!
What is missing here for me is a ability to test links. Text which you can see for the first item on the list is not necessary a page name (it might be a clickable text) so it's impossible to figure out from this view what page is referenced.
Funny thing is that title for this link has a following form:
It is very useful isn't it? ;) I think the simplest solution would be to make link text clickable.
After clicking on 'Add Link' or 'Edit' button you will get old popup:
There are no surprises here, it's an old well-know dialog.
Lets check now how to deal with Link collection in a code. It's quite common to use Repeater to display links:
1: <asp:Repeater ID="rptRelatedLinks" runat="server">
3: <ItemTemplate><dt><asp:HyperLink runat="server" ID="hplMainLink" /></dt></ItemTemplate>
1: PropertyLinkCollection links = (PropertyLinkCollection) CurrentPage.Property["RelatedLinks"];
2: rptRelatedLinks.DataSource = links;
And a method populating the Repeater:
1: void rptRelatedLinks_ItemDataBound(object sender, RepeaterItemEventArgs e)
3: if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
5: LinkItem linkItem = (LinkItem) e.Item.DataItem;
6: HyperLink link = (HyperLink) e.Item.FindControl("hplMainLink");
8: // mapped link has a form like:
9: // <a href="/Templates/Public/Pages/Page.aspx?id=16&epslanguage=en" target="_blank"
10: // title="this is link title">Information about the meeting</a>
11: string mappedLink = linkItem.ToMappedLink();
13: // permanent link form:
14: // <a href="~/link/bb6aa3227f8f467bbe1a42154cb56ba5.aspx" target="_blank"
15: // title="this is link title">Information about the meeting</a>
16: string permanentLink = linkItem.ToPermanentLink();
18: // because Href property will return permanent link like
19: // ~/link/bb6aa3227f8f467bbe1a42154cb56ba5.aspx
21: // it's necessary to use PermanentLinkMapStore.ToMapped(url) to covert it to normal form
22: // result is required to determine if conversion was successful
23: // it will fail for mails (mailto:firstname.lastname@example.org), documents and external links
24: UrlBuilder url = new UrlBuilder(linkItem.Href);
25: bool result = PermanentLinkMapStore.ToMapped(url);
27: link.NavigateUrl = result ? url.ToString() : linkItem.Href;
28: link.Text = linkItem.Text;
29: link.ToolTip = linkItem.Title;
30: link.Target = linkItem.Target;
My overall impression is positive, new property Link collection is easy to use but for sure there are things which could be improved like ability to test a link or ability to define page root to look for pages to include. It's a hassle to always start from the very top!
I wonder now if there is still a reason to use old Multipage property, what do you think?