https://github.com/zetlen/alternative-view
Declarative logic-driven template selection for Mozu storefronts.
https://github.com/zetlen/alternative-view
Last synced: 10 months ago
JSON representation
Declarative logic-driven template selection for Mozu storefronts.
- Host: GitHub
- URL: https://github.com/zetlen/alternative-view
- Owner: zetlen
- Created: 2015-07-23T16:48:44.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-08-14T20:07:37.000Z (almost 11 years ago)
- Last Synced: 2025-01-16T10:10:14.116Z (over 1 year ago)
- Language: JavaScript
- Size: 176 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# alternative-view
### version 0.1.0
Declarative logic-driven template selection for Mozu storefronts
http://www.infinitelooper.com/?v=6_9blTxwFeA&p=n#/110;123
## An alternative view?
Mozu Themes are incredibly powerful, but there are just a couple of places where you might wish they had more power than they do. For instance, in your `theme.json` file, you declare `pageTypes` that bind a type of storefront page to a particular Hypr template:
```json
{
"documentType": "web_page",
"entityType": "webpage",
"id": "home",
"template": "home",
"title": "Home Page",
"userCreatable": true
},
```
This declares that webpages assigned the "home" template must use a template in the theme called `templates/pages/home.hypr`. (The `"template"` configuration option expects the name of a file in that particular directory.)
In SiteBuilder, a merchant can assign web pages (or product pages, or category pages!) to alternate templates one by one, by changing their Page Settings.
But what if you want to do this dynamically?
### AlternativeView can change the Hypr template a page uses based on rules.
Install AlternativeView, and then add rules to your Action Configuration. Want to change the template of a category page if a URL query parameter `alternate` is set to `true`? Add a template called `category–alternate.hypr` to the `templates/pages` folder of your theme, and then add the following rule to your `configuration` in Action Configurations:
```json
"rules": [{
"type": "queryparams",
"params": {
"alternate": true
},
"viewName": "category-alternate"
}]
```