Developer forum

Forum » Dynamicweb 10 » Render page content via link field

Render page content via link field

Joakim
Reply

Our client is running version 10.21.10. We're trying to render page content from a page recieved via link in backoffice. 


So in Swift_ProductListInfo.cshtml we're using the ID from field CMS content page to render all content from that page. 

This is easily solved with javascript but we're wondering if there is a method or another way to go about this?

The current code we've landed with is:

var page = Dynamicweb.Content.Services.Pages.GetPage(cmsContentPageIdValueParsed);
var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(page);

Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

In your template you can call @RenderGrid(pageId) and get the grid output - but not the rest of the page.

You can get the markup of the page using PageView.GetPageviewAsTemplate()

var pageviewAsTemplate = PageView.GetPageviewAsTemplate(pageId);
<div><@pageviewAsTemplate.Output()</div>

You can execute a pageview:

var pageview = PageView.GetPageviewByPageID(pageId)
<div>pageview.Output()</div>
 
Joakim
Reply

Neat!

However, we wish to only render the content inside #content


Would this be achievable?

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Depending on your implementation, that would be RenderGrid

 

You must be logged in to post in the forum