Developer forum
E-mail notifications
Change page template querystring
Is it possible to change the page template via the querystring in DW?
Replies
You can do that with a query string parameter called LayoutTemplate as explained in the document about Designs and Layouts: http://developer.dynamicweb-cms.com/documentation/for-designers.aspx
The path you pass should start with the Designs folder. E.g.:
http://developer.dynamicweb-cms.com/?LayoutTemplate=Designs/Condition/Print.html
Hope this helps,
Imar
Hi Imar,
I cannot get that to work. I can however parse a template with &template=TemplateFileName.Html,
though not make use of the template tags within (i am trying to create a seperate print template for catalogh publishing in the eCommerce module. Has to create a print and pdf version - both in landscape model.
/MikkelTO
It works for me. Compare these two URLs:
http://developer.dynamicweb-cms.com/forum/cms-standard-features/cms-standard-features/change-page-template-querystring.aspx?LayoutTemplate=Designs/Dynamicweb2011/Subpage.html
http://developer.dynamicweb-cms.com/forum/cms-standard-features/cms-standard-features/change-page-template-querystring.aspx
Can you define "cannot get that to work"?
Imar
http://silhorkosandbox.net.dynamicweb-cms.com/Default.aspx?ID=10121&LayoutTemplate=Designs/print_silhorkoProduct.html
is not working for me. Or, it does render the template - however, I am not able to output the values from the "original" template onto the parsed template.
/MikkelTO
>> however, I am not able to output the values from the "original" template onto the parsed template.
What do you mean with this? Templates don't have values, they have tags to display values. The query string LayoutTemplate replaces the layout template for the page completely, as if you had selected it on the Layout tab of the Ribbon bar.
Can you elaborate on what you're trying to accomplish?
Imar
Hi Imar,
Of couse I meant the tags which displays values. I am parsing an alternate template to a product template (in order to make a print friendly page for this - and a PDF as well). Though I can't seem to output the Ecom tags on it. E.g. Ecom:Product.ID etc. on the alternate template. I hope it made a bit more sense :-)
/MikkelTO
Oh, I see. That won't work. LayoutTemplate sets the Layout Template, not individual module templates.
In the case of the Product Catalog module you can pass a View parameter. For example, assuming your List template for the Product Catalog is called product-list.html, passing a ?View=print parameter would load the template product-list_print.html instead.
Hope this helps,
Imar
Another approach could be a copy of the page - so you have 2 versions showing the exact same content, but with different templates though.
BR Nicolai
The layout context is your friend! If your page uses a layout template called «template».(cs)html, then you can add your module templates inside a folder called «template»/ and then the module templates inside this folder will be used if they exist.
Example: This page uses the default layout template (Page.cshtml): http://mri.net.dynamicweb-cms.com/?id=415. On this page we have a product catalog using the template eCom/ProductList/ProductList.html.
Using the LayoutTemplate query parameter we can show the page using another template (Page.pdf.cshtml): http://mri.net.dynamicweb-cms.com/Default.aspx?id=415&LayoutTemplate=Designs/examples/Page.pdf.cshtml. This changes the layout context (to Page.pdf) and now the Product List automagically uses the template Page.pdf/eCom/ProductList/ProductList.html.
Best regards,
Mikkel
Hi Mikkel,
That makes sense, however I am working on an old solution which means the setup is a bit different. E.g it does not use the design structure: Designs/DesignName/ etc.. The different templates are located in the Page folder, eCom folder etc. I dont know if this has any influence? - I might be overlooking something, however I am not able to replicate your example - unfortunately.
You must be logged in to post in the forum