Developer forum

Forum » Dynamicweb 10 » Standard DW10 templating

Standard DW10 templating

Kevin O'Driscoll
Reply

Hi we have started to upgrade some DW9 sites to DW10. The DW9 sites were upgraded to the recommended versions and the code (custom and API) updated accordingly.
We have created a DW 10.21.5.0 and the setup went well on my local development machine (using the powershell installation method).
We would like to maintain our way of using our current template set up with Dw_Frontpage.cshtml referencing a Main.cshtml, but using the new

@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
and
@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel>

with the content being rendered with @RenderBody in the Main.cshtml

We have some issues rendering paragraphs however (very simple standard paragraphs, not item types)
We use @Model to get some Page properties like @Model.ID and @Model.Path. Even @Model.Cart.TotalProductsCount and @Model.Cart.CartOrderlines
For Paragraphs we see @Model.Text and @Model.Image etc in our intellisense, but the paragraphs just dont render.
I expected there would be @Model.Paragraphs in the PageViewModel?

Could anyone give us a heads up on how to put together a standard way of doing this in DW10?

Rds

Kevin


Replies

 
Claus Kølbæk
Claus Kølbæk
Reply

Hi Kevin

I am not enterily sure about the issue you are facing, but maybe enabling the the option "Use parsed layouts for razor layout templates" under Settings -> Administration -> Feature Management, can help you. - It generally seem to be something needed when upgrading from a 9 to a 10.

 
Kevin O'Driscoll
Reply

Hi Claus thanks for replying. I tried this but it appears that this is to do with switching on or off the template parsing feature. This is great if switched off while debugging and switched on while in production.

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Kevin

You will not want the "Use parsed layouts for razor layout templates" feature turned on unless you have a very old HTML based implementation or an odd old type "content placeholder" implementation with some very specific razor syntax from old days.

If you are using Swift 1 or Swift 2 or an implementation made on the grid system in the past 4-5 years, you do NOT want that option on. It is to activate a deprecated layout system.

If you are implementing a new solution, ensure you use the latest implementation method for layout templates described here: https://doc.dynamicweb.dev/documentation/implementing/content/designs-layouts.html

 
Kevin O'Driscoll
Reply
Thanks for this Nicolai, it's good to know about _Parsed files usecases in DW10. 
As we upgrade to DW10 we try to expel older code and bring in the new also for the .NET Core folder layouts for web apps, even if some apps are very old, hence we sometimes struggle doing everything the new way. 
 
We have however succeeded in rendering standard paragraphs and most Item Type Templates including some @Include.. templates
We have used, from the Dynamicweb.Frontend.PageViewModel (in Main.cshtml)
<main>
@Model.Placeholder("content", "Content")
</main>
 
But now we are attempting Navigation and that will be another forum post I guess...
 
Meantime Happy New Year to all at Dynamicweb and forum members.
 
Best Regards,
Kevin

 

You must be logged in to post in the forum