viewby

viewby

This function generates the current template tag to be applied to the page.

Example

[%viewby type:'products'/%]

Usage

The above result would print gallery by default, which is Neto's default name for the template.html thumbnail template. You can change this by either changing the config for the default view type in the Webstore Settings or javascript for having the customer change it in the session like so:

href="javascript:viewtype('list');"

The viewby function can also be used with a condition:

[%viewby type:'products' if:'eq' value:'list' if_true:'thumb_list' if_false:'thumb' /%]

If the current setting of [%viewby type:'products'/%] is list, return thumb_list, otherwise return thumb. This example is used to select the CSS class in the category.template.html template.

Default Setting

To change the default thumblist layout for the site, go to Settings & tools > All settings & tools > Web Store > Webstore Settings. In the List Settings section, change the dropdown next to Default thumbnail layout for product listings and save the change.

By selecting Other, you can add a custom template name. Enter the name without .template.html. Then create a template in the templates/thumbs/product/ folder of the theme.

Parameters

Name Options Description
if:'' eq, ne Checks if value:'' is equal (or not) to the default thumblist layout or what the customer selected
if_false:'' String Returned value if the condition is not true
if_true:'' String Returned value if the condition is true
type:'' products Specifies the type of content you are loading the default template for, currently products is the only option
value:'' gallery, list, custom By default it loads the Default thumbnail layout for product listings setting from the control panel, but can be forced to load a specific value

Was this article useful?

Be notified when this page is updated. Optional.