Developer forum

Forum » CMS - Standard features » Folder contents list in items

Folder contents list in items

Anders Engelbøl
Reply

Hi DW,

 

Now that you're so fond of items, you may be able to help me solve a slight issue I have here. I'm trying to get rid of the "old" filepublish module, but I'm stuck when it comes to the issue of setting a path to a folder, and list its content, i.e. in a simple <ul> list. Is that in any way possible with items, and how?


Replies

 
Mikkel Ricky
Reply

You can use the Folder item field for this (see http://manual.dynamicweb-cms.com/Default.aspx?ID=7592#31798).

In your template you can list all files in the folder selected in your item like this (assuming your field is called Folder)

@foreach (var file in GetLoop("Item.Folder.ListOfFiles")) {
    <pre>@file.TemplateTags()</pre>
}

Best regards,
Mikkel

 
Nuno Aguiar
Reply

Hi Mikkel,

 

We are trying to apply this on a product detail (eCom), getting the folder from the Area (an item).

 

This means that I don't have the folder loop on the eCom Product detail, so how could I loop though the files getting the folder path through the API?

 

Best Regards,

Nuno

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

You cannot use the loop, but you can access the item and the property data using

@Pageview.Area.Item["Item.Folder.ListOfFiles"]

But it will not give you the loop, so you have to manage some data your self.

Or you can make a product template extender that renderes the area item on the product detail - it has to do something like this:

Dynamicweb.Content.Items.Rendering.Renderer.RenderAreaItem(Pageview.Area.Item, templateInstance);

Make sure that you DO NOT do this on product lists, but only on product detail.

BR Nicolai

Votes for this answer: 1
 
Nuno Aguiar
Reply

Hi Nicolai,

 

Thanks for that.

 

Best Regards,

Nuno

 

You must be logged in to post in the forum