Developer forum

Forum » CMS - Standard features » Using ParagraphRender to render Visual Editor content

Using ParagraphRender to render Visual Editor content

Mikkel Belchuke
Mikkel Belchuke
Reply

Hi. 

I'm trying to render the content, from another page, inside my product details page. The product details page is using RazorTemplateModel and the content I'm trying to render is using ViewModelTemplate. 

When I use:

@RenderParagraphContent(paragraph.ID) I only get the paragraph title. 

Is there a way to display all the content?


Replies

 
Anders Ebdrup
Anders Ebdrup
Reply

+1

 
Nicolai Pedersen
Reply

Are the 2 pages in the same layout context? Both being rendered on the same layout file? And if not, do one of them happen to have layout dependent paragraph templates? And if so, try moving the shared templates to the "_shared" folder - /design/_shared/paragraph"

 
Mikkel Belchuke
Mikkel Belchuke
Reply

They're both in the same context. Both in the same design folder at least. 

I try to render content from the new Visual Editor, so might be something there. 

 
Nicolai Pedersen
Reply

Yes, same design folder, but not same layout folder. Take a look at that.

 
Mikkel Belchuke
Mikkel Belchuke
Reply

Okay, let me see if I get this:

My current structure is like this.

 

For the content I try to render:

/Designs/{{DESIGN}}/ContentPage/Paragraph/StandardParagraphTwo.cshtml

For the product page where I try to render the content

/Designs/{{DESIGN}}/eCom/Product/ProductDetails.cshtml

 

What you are suggesting is that I try to create a top layout folder named "_shared", and move the structure inside this, so it will look like this:

For the content I try to render:

/Designs/{{DESIGN}}/_shared/ContentPage/Paragraph/StandardParagraphTwo.cshtml

For the product page where I try to render the content

/Designs/{{DESIGN}}/_shared/eCom/Product/ProductDetails.cshtml

 

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Nope.

The paragraph you try to render, might be in one layout. And the paragraph that renders the product catalog uses another layout. I.e. "Fullpage.cshtml" and "ProductListPage.cshtml".

If the page that holds the paragraph you want to include, uses "fullpage" template, then "fullpage" will be the layout context for that paragraph. If the paragraph is then rendered with a paragraph template called {Design}/fullpage/Paragraph/sometParagraphTemplate.cshtml and the product page is rendering in "ProductListPage" context, the paragraph template cannot be found and hence the paragraph rendering will fall back to the default paragraph template found in the "ProductListPage" layout context - that would be either {Design}/ProductListPage/Paragraph/Default.cshtml or {Design}/Paragraph/Default.cshtml.

Not simple, I know. Bottom line - you have to ensure that both the page that renders the product detail and the page that renders the "global" paragraph has to share context.

See my dumps that it works.

Capture.JPG Capture2.JPG
Votes for this answer: 1
 
Mikkel Belchuke
Mikkel Belchuke
Reply

That's super. It works! 

To anyone who might have the same issue; you need to copy the paragraph from ContentPage/Paragraph to /Paragraph nad remember to change the location of the Included ParagraphBase.cshtml:

 

 

2020-06-03_0741.png

 

You must be logged in to post in the forum