Developer forum

Forum » CMS - Standard features » How to render item based paragraph?

How to render item based paragraph?

Davor Zlotrg
Reply

Hi DynamicWeb,

I have item based paragraph (item list) that has own .cshtml Template. Template is just ordinary dropdown where options are rendered as content of item list. This is working when I open page of that paragraph and everything is rendered correctly.

I would like to render that item based paragraph on my master page.

<!--@Global:Paragraph.Content(id)--> is not working, as I also found in documentation that it will not work for item based paragraph. ("If the paragraph content is item based then you need to use a paragraph template that use item tags or loops for the given paragraph that you use in the Global:Paragraph.Content tag in order to render the item based content.")

Please advise how to render this item based paragraph template on my master page?

Do we have possibility to choose product group item field type where we could choose product groups from eCommerce? (I know we have Product item field type and we can choose products from eCommerce)

Kind regards,

 


Replies

 
Mikkel Ricky
Reply

Using <!--@Global:Paragraph.Content(id)--> with item based paragraphs work fine for me (on latest version of Dynamicweb 8.4.1). The documentation just (tries to) make it clear that you need a paragraph templates that can show your item based paragraph template, but you already have that.

How does it not work? Can you show us an example?

Depending on your specific case it may actually make more sense to use an "Item list" field on an item used as website properties to do what you want to do. The you can easily render the list of items in your (master) page template.

Best regards,
Mikkel

 
Davor Zlotrg
Reply

Hi Mikkel,

We are using also 8.4.1.6 version (so that should not cause the issue). Actually we are using "Item list" field which uses other item type as parameters.

It just does not render anything. This div with class="content" is empty after website loads. This is part of html in my master.cshtml

                <div class="grid_1 alpha omega">
                    <div class="content">
                        <!--@Global:Paragraph.Content(3472)-->
                    </div>
                </div>

Also attached is screenshoot of my paragraph where you can see ID of paragraph.

I am also sending you the link to the site so you could check (if needed):

http://195.249.142.64/Admin

Kind regards

Paragraph.PNG
 
Mikkel Ricky
Reply
This post has been marked as an answer

The paragraph you're trying to render is using a paragraph template called ProductCenterNew.cshtml, and this paragraph template only exists in the folder subpage/Paragraph/ inside your design folder. When you're rendering a page using a layout templates other than subpage.cshtml, this paragraph template cannot be found and therefore nothing is rendered when rendering the paragraph.

The fix: move ProductCenterNew.cshtml to the Paragraph folder in your design folder or, alternatively, create a new paragraph template, elsalg/Parapgraph/ProductCenterNew.cshtml, and include the existing paragraph template

@IncludeFile("../subpage/Paragraph/ProductCenterNew.cshtml")

Best regards,
Mikkel

Votes for this answer: 1
 
Davor Zlotrg
Reply

Thanks Mikkel, it is working now.

Kind regards,

 

You must be logged in to post in the forum