Developer forum

Forum » CMS - Standard features » RenderItemList

RenderItemList

Peter Terkildsen
Reply

Hi,

I'm trying to render an ItemList in a module template. The item is an ItemList that is being used on the website level. However, I'm not able to get anything published. Can you see what I'm doing wrong?

                foreach (LoopItem item in GetLoop("Coordinates"))
                {   
                    @RenderItemList(new {
                        ItemType = "Department_Facts",
                        ListSourceType = "ItemList",
                        ListSourceArea = 1,
                        ItemFieldsList = "*",
                        ListPageSize = 4,
                        ListOrderBy = "Created",
                        ListTemplate = "modules/nearestplace.cshtml"
                    })
                }


Replies

 
Mikkel Ricky
Reply

Your ListTemplate value must start with "ItemPublisher/List/", e.g. ItemPublisher/List/nearestplace.cshtml (cf. http://templates.dynamicweb.com/TemplateTags/Dynamicweb-template-tags/Module-tags/Item-publisher/Item-Render.aspx).

Best regards,
Mikkel

 
Peter Terkildsen
Reply

Ok, I tried changing this path but unfortunately it doesn't work either. The template appears just fine whether or not I place the template in the ItemPublisher-folder or not.

I suspect that the problem is that I'm using an ItemList, and I don't have a method to select the precise ItemList - like ListSourceItemList = 1 instead of ListSourceArea = 1.

Is RenderList able to render an ItemList?

 
Mikkel Ricky
Reply

RenderList works just like the item publisher (module) and can only render items used as pages or paragraphs.

Items used in item lists are conceptually a part of the containing item and therefore it does not make sense to render them outside the context of the containing item.

Best regards,
Mikkel

 

 

 
Peter Terkildsen
Reply

Ok, so there is a logical explanation then.

However, then again I think it's a shame that you cannot maintain a central Itemlist which you can then render in whatever template. :-)

Thank you for answering me

 
Mikkel Ricky
Reply

You can maintain a list of items that you can render in any template. Just create a list of item based pages or paragraphs somewhere, e.g. in a folder or an hidden page, and publish these items using @RenderList. 

 
Peter Terkildsen
Reply

Got it - I modified the code and the item. It works now with the following:

@RenderItemList(new { ItemType = "Department_Facts", ListSourceType = "Page", ListSourcePage = Base.ChkInteger(Pageview.Area.Item["PointsOfInterestPageID"].ToString().Replace("Default.aspx?ID=", "")), ItemFieldsList = "*", ListPageSize = 4, ListOrderBy = "Created", ListTemplate = "NemLejeV2/poi.cshtml", IncludeParagraphItems = true });

 
Mikkel Ricky
Reply

Cool. You should consider using the "Select only page or paragraph ID" option to get rid of all the Replace stuff inside ListSourcePage.

 
Peter Terkildsen
Reply

Hi again,

I did that, but that feature only seems to work when I select a certain paragraph. It doesn't work when I select a page. I don't like the Replace-crap either :-)

 

Peter

 

You must be logged in to post in the forum