One Blog, Multiple Templates?

Highlighted
Tourist
5 0 0

I have a blog for a flooring/remodeling company. The current blog.liquid template includes a Quote Request form in the footer (under Next/Previous and Social Share buttons).

I would like to create a secondary template to have the option to remove the Quote Request form on some blogs, if we are using a different form (or some other need to remove the form) on that post.  Same blog parent, different template based on form needs.

Is this possible?

0 Likes
Highlighted

Hi bseeber

 

Yes, this is 100% possible. What you actually want to create an alternative template for is the Article (also known as Blog Post) not the blog. This would allow you to individually select which blog posts show which forms based on the alternative templates. To do this, you will need to click on the "Edit code" option from the Actions drop-down menu. In the code editor on the left, find the template folder and click "Add a new template". Select article from the drop-down menu and then give it a name such as "no-form" or something descriptive.

 

Then you will want to create a new article section in the Section folder with a name such as: "article-template-no-form". In the article template you made earlier it would have have the following line in it:

{% section 'article-template' %}

Change that to the new name you gave the section you just created. Now go into your original "article-template" section and copy all the code and paste it into the section you just created.

 

From this point, you need to remove the code that generates the form in your article blogs from the section you just created. Unfortunately, I cannot tell you what this is without looking at your code in your store.

 

Once all this is done, next time you create a blog post you will get the option to select a template file and your new template name will be available!

 

If you would like some help with making this change or any further customizations or support, feel free to send me an email at support@microDev.today and we can see how we can help you.

 

All the best!

0 Likes