EPiServer CMS5 Softlinks. How to find a documents linking pages
by Rizo on jun.25, 2009, under Developing
Using EPiServers softlink can really come in handy in different situations. Mostly of course when you need to gather information from the linked pages of a document.
Here’s an example on how to use this:
Example in VB.Net
[sourcecode language=’vb.net’]
Dim f As EPiServer.Web.Hosting.UnifiedFile = TryCast(System.Web.Hosting.HostingEnvironment.VirtualPathProvider.GetFile(filename), EPiServer.Web.Hosting.UnifiedFile)
Dim filecollection As EPiServer.DataAbstraction.SoftLinkCollection = EPiServer.DataAbstraction.SoftLink.Load(f)
For Each file As EPiServer.DataAbstraction.SoftLink In filecollection
Dim ref As New PageReference
ref = file.OwnerPageLink
’now you can work your magic
Next
[/sourcecode]
Example in C#:
[sourcecode language=’c#’]
EPiServer.Web.Hosting.UnifiedFile f = System.Web.Hosting.HostingEnvironment.VirtualPathProvider.GetFile(filename) as EPiServer.Web.Hosting.UnifiedFile;
EPiServer.DataAbstraction.SoftLinkCollection filecollection = EPiServer.DataAbstraction.SoftLink.Load(f);
foreach (EPiServer.DataAbstraction.SoftLink file in filecollection) {
PageReference ref = new PageReference();
ref = file.OwnerPageLink;
//now you can work your magic
}
[/sourcecode]
So what you need to do is pretty much to load up the file reference into a softlink and fill a softlinkcollection with that. Then just run a for each on the collection (since a document can have several linking pages). Once you get your reference, you can just do a getpage on the ref and grab whatever you need from the linking page.
9 Trackbacks / Pingbacks for this entry
oktober 2nd, 2023 on 06:46
… [Trackback]
[…] Find More here to that Topic: from-rizo.se/episerver-cms5-softlinks-how-to-find-a-documents-linking-pages/ […]
november 5th, 2023 on 05:27
… [Trackback]
[…] Find More to that Topic: from-rizo.se/episerver-cms5-softlinks-how-to-find-a-documents-linking-pages/ […]
december 11th, 2023 on 03:38
… [Trackback]
[…] Find More to that Topic: from-rizo.se/episerver-cms5-softlinks-how-to-find-a-documents-linking-pages/ […]
april 22nd, 2024 on 00:17
… [Trackback]
[…] Read More on to that Topic: from-rizo.se/episerver-cms5-softlinks-how-to-find-a-documents-linking-pages/ […]
maj 29th, 2024 on 14:44
… [Trackback]
[…] Read More here on that Topic: from-rizo.se/episerver-cms5-softlinks-how-to-find-a-documents-linking-pages/ […]
juni 21st, 2024 on 01:08
… [Trackback]
[…] Read More to that Topic: from-rizo.se/episerver-cms5-softlinks-how-to-find-a-documents-linking-pages/ […]
juli 8th, 2024 on 01:59
… [Trackback]
[…] Read More on that Topic: from-rizo.se/episerver-cms5-softlinks-how-to-find-a-documents-linking-pages/ […]
juli 18th, 2024 on 04:00
… [Trackback]
[…] Read More on to that Topic: from-rizo.se/episerver-cms5-softlinks-how-to-find-a-documents-linking-pages/ […]
augusti 17th, 2024 on 02:59
… [Trackback]
[…] Information to that Topic: from-rizo.se/episerver-cms5-softlinks-how-to-find-a-documents-linking-pages/ […]