Developer forum

Forum » CMS - Standard features » Publish ItemTypes that are not in Lists, Paragraphs or Pages

Publish ItemTypes that are not in Lists, Paragraphs or Pages

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Guys,

I have other threads covering about the same topic but they migth be buried deep in the forum, and I wanted to revert back to this issue and hopefully find a solution for it.

I have an Item type with an Item Relation field with the option "Inline" set to it.

I can define values in it without any issues but I am not able to list them anywhere. The ItemPublisher looks by default for either pages, paragraphs or ItemLists. I have neither.

I am looking for a way to list them using the API and still retain the way the fields inside it are defined (loops, booleans, files, ItemRelations, products etc).

I was thinking maybe something similar with Dynamicweb.Content.Items.Item.GetItemById("ITEM_SYSTEM_NAME", itemId).

Thank you in advance,
Adrian


Replies

 
Vladimir
Reply

Hi Adrian,

I think it is possible with RenderItemList function (it is Item Publisher extension tag):  

http://doc.dynamicweb.com/documentation-8/content/items/item-publisher

RAZOR:

@{
    var myListId = GetInteger("Item.MyList");
    var itemList = ItemList.GetItemListById(myListId);  
    
    RenderItemList(new
    {
        ItemType = itemList.ItemType, 
        ListSourceType = "ItemEntries",
        SourceItemEntries = String.Join(",", itemList.Relations.Select(r => r.Id)),
        ItemFieldsList = "*",
        ListTemplate = "ItemPublisher/List/List.html"
    });
}

I hope this helps.

Kind regards,

Vladimir

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Vladimir,

Thank you for your response.

I tried with RenderItemList but not with the example you gave. I believe I was missing the first comma.

I will give it a try.

Thank you,

Adrian

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Vladimir,

I have tried your approach but unfortunately it still does not render Items that are just in the Item relation. 

Or it's possible that I am missing something.

In order to test it, I used your approach, set a template then load the page.

The list of Id's was rendered correctly but no item was rendered.

Then, I have added a page based on the same itemtype and I have manually added the ID in the list.

This time it rendered the item I just added.

Any other ideas?

Thanks,

Adrian

 
Vladimir
Reply

Hi Adrian,

indeed, you are right - this way we could get only "Content" items...

Sorry for incorrect answer. It seems in curent moment it possible to render details only in loop:

        @{
            var myListId = GetInteger("Item.FldList");
            var itemList = ItemList.GetItemListById(myListId);  
            <ul>
            @foreach (var item in itemList.Relations)
            {
                <li>            
                @RenderItemList(new
                {
                    ItemType = itemList.ItemType, 
                    SourceItemEntry = item.Id,
                    ItemFields = "*",
                    DetailsTemplate = "ItemPublisher/Details/Details.html"
                })
                </li>
            }
            </ul>
        }

I will send a request to make upper way usable too

 

Kind reards,

Vladimir

 

You must be logged in to post in the forum