alternate index template

Highlighted
New Member
7 0 0

Hi

I'm a bit confused as to why I can create an alternate template for index.liquid, yet I can't set it anywhere:

I want to create 2 templates for the home page layout, that can be set through Theme Settings. So, one month might have more promotions or less, but the layout can be governed by a setting, this way it has the benefits of presets etc.

I assume that because the option to create a new template of the type 'index' exists that means this is possible, but this post suggests otherwise: 

http://ecommerce.shopify.com/c/ecommerce-design/t/alternate-index-and-theme-112030

Is it possible to access this through the theme template in liquid? or is my other option to create an alternative page layout and pull this into index.liquid?

many thanks

0 Likes
Shopify Staff
Shopify Staff
5826 0 252

It may be possible to access an alternate index template using this URL:

/?view=alternate

if your index template is called index.alternate.liquid.

Similarly:

/?view=caroline

if your index template is called index.caroline.liquid.

If that works, that would be the extent in which you can use alternate index templates.

To change the content of your home page, use a page setting in your theme settings, alternating the page shown on the home page. You can also add a collection theme setting, alternating which collection to feature on your home page, etc.

It's very rare that layouts are useful. They are to be avoided as much as possible, they break down everything into dupes that you need update together when you fix or improve anything. Use a body class and body ID to vary what's happening, instead of an alternate layout.

<body class="{{ template | replace: '.', ' ' | truncatewords: 1, '' }}" id="{{ page_title | handle }}">

Use CSS with descendant selectors, or JavaScript that checks the body class and id.

Caroline from http://11heavens.com ∴ mllegeorgesand AT gmail DOT com
0 Likes
New Member
7 0 0

Thanks Caroline /?view=alternate shows the alternate index template. I'd have to redirect to this URL to get the different content right?

But the second part - populating a select with 2 different home pages is not related to the above is it? It sounds like to do what I want, I'd have to create 2 different page templates and select these through a drop down in the theme settings.

thanks

0 Likes
Shopify Staff
Shopify Staff
5826 0 252

I'd have to redirect to this URL to get the different content right?

Yes, you'd need to. 

But the second part - populating a select with 2 different home pages is not related to the above is it?

No. A page selector lets you select a 'page' page, not a template.

This said I have an idea: you can have a snippet selector on the theme settings page, and could add your content A to snippet-home-page-A and content B to snippet-home-page-B, and add a snippet selector for your home page content in settings.html.

Index.liquid would use:

{% include settings.home-page-snippet %}

And your theme setting, in settings.html, would be:

<label>Snippet for home page</label>
<select class="snippet" name="home-page-snippet" />

 

Caroline from http://11heavens.com ∴ mllegeorgesand AT gmail DOT com
0 Likes
New Member
7 0 0

Sweet, sounds like a plan

thanks Caroline!

0 Likes
New Member
7 0 0

Actually made this a bit cleaner for the client to admin by setting up a radio button group in the settings.html then using some logic to index.liquid to set a variable to either layout1 or layout2. Then including the layout snippet with this variable. Inside the snippet is some logic to output the right layout.

0 Likes