Developer forum

Forum » CMS - Standard features » Change page template querystring

Change page template querystring

Kim Søjborg Pedersen
Reply
In umbraco you can write something like localhost/somepage.aspx?altTemplate=someTemplate and that page is rendered by that template

Is it possible to change the page template via the querystring in DW?

Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
This post has been marked as an answer
Hi Kim,

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

Votes for this answer: 0
 
Mikkel Toustrup Olsen
Reply

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

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

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

 
Mikkel Toustrup Olsen
Reply

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

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

>> 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

 
Mikkel Toustrup Olsen
Reply

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

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

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

 
Nicolai Høeg Pedersen
Reply

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

 
Mikkel Ricky
Reply
This post has been marked as an answer

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

Votes for this answer: 1
 
Mikkel Toustrup Olsen
Reply

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