A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

AI OnAI Off

List PageFiles for each page in a PageList

Vote:
 

I would very much appreciate any ideas on how to show a list of PageFiles for each page in a PageList.

Br

Petter 

#59673
Jun 20, 2012 13:46
Vote:
 

You could add a ItemDataBound event and then check the pagefiles for each item and list them if you so wish.

See: http://antecknat.se/blog/2008/12/19/episerverpagelist-with-itemdatabound/

#59674
Jun 20, 2012 14:34
Vote:
 

Thanks Petter.

Tried to download the source code for the original project for your link, but it seems that this was removed.

Being av newbie I found this a bit over my head and solved the problem in a less elegant way...

Petter

#59693
Jun 22, 2012 8:15
Vote:
 

The good old <%#GetListOfFiles(Container.CurrentPage)%> ?

#59694
Jun 22, 2012 9:04
Vote:
 

Hi Anders.

This would be very nice and simple, but GetListOfFiles does not exist inside the ItemTemplate of the PageList - At least not here...

Any suggestions?

Petter

#59695
Jun 22, 2012 9:12
Vote:
 

Hi Anders.

My previous answer really place me as an EPiServer developer...

At first glance, I thought that you came up with an EPiServer solution to a known problem...

But I think that you are implying that I need to write my own method (GetListOfFiles).

If I should do this, I would like to display the files in a list with the filename as a hyperlink, the time it was uploaded, and the name of the user that uploaded. How would you solve this as opposed to write a method that returns a string to be diplayed inside a lebel control?

Petter

#59696
Jun 22, 2012 11:16
Vote:
 

Hi

You are correct. I meant that you had to make the method yourself, or use this as a base:

public string GetListOfPageFiles(PageData page)

{

    string result = "";

    var dir = page.GetPageDirectory(false);

    if (dir != null)

    {

        foreach (var fil in dir.GetFiles())

        {

            string name = fil.Name;

            if (fil.Summary != null && !string.IsNullOrEmpty(fil.Summary.Title))

               name = fil.Summary.Title;

            result += "<li><a href=\"" + fil.VirtualPath + "\">" + name + "</a></li>";

        }

    }

    if (result != "")

        result= "<ul>" + result + "</ul>";

    return result;

}

 

    

#59697
Edited, Jun 22, 2012 11:50
Vote:
 

The fil.Summary attributes gives you some data about the fil, and the fil object have some others

#59698
Jun 22, 2012 11:51
Vote:
 

That's great Anders.

I have been working with EPiServer/asp.net for 6 months now with no prior experience what so ever with c#/Visual Studio (I've worked with Delphi the last 10 years).

What I find the most frustrating with asp.net is that there are sooo many ways to solve a given task....

Thanks for the help - this will solve the task, and I will probably understand the code some time in the future.

#59701
Edited, Jun 22, 2012 13:05
error This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.