MMv4 KB
 
Universal Template
  Last Edited - 03/31/2018 9:56pm PDT
  Category Path - Glossary
 
The shopping cart software's public-facing storefront, where customers come to shop, consists of several pages, including a "product information" page, a "view my basket" page, a "checkout" page, etc. In all, there are roughly 36 different storefront pages that your customers can visit.

Each of these 36 storefront pages has a corresponding template, which contains the HTML, CSS and JavaScript code that controls the page's design.

A Template Package is a set of these templates, one for each section of the store's administration area.

and the question we're inevitably asked next is...
So, you're telling me that, in order to design my storefront, I have to create HTML templates for thirty-six different pages? I'm so busy that I barely have time to hard boil an egg1, let alone replicate a web design three dozen times!

Fortunately, it is not necessary to create a web design for each of the 36 templates if you don't want to. That's where the Universal Template comes in. You now have the option to make an entire Template Package that consists of just one single "universal" template!

Here's how it works. If a storefront page's regular template is not present in a Template Package, then the universal template will be used instead.
 
Here is an example, in flowchart form:


What the flowchart is saying is that the storefront's product page uses a template named product.tpl. When a product's page is viewed by a customer, the shopping cart software first checks to see if the product.tpl file is present in the store's live Template Package.

If the product.tpl template isn't found, then the contents of the universal.tpl template are used instead.

In addition to the same HTML, CSS and Javascript used by the other templates in the template package, the universal.tpl file also contains the QuickCode Tag {UNIVERSAL-CONTENT}. This QuickCode Tag is special because the shopping cart will replace it with the default content that's appropriate for the page being viewed. For example, on a product's page, the {UNIVERSAL-CONTENT} QuickCode Tag will be replaced with the name, price, description and "add to cart" button for the product.

The content displayed in the place of the {UNIVERSAL-CONTENT} QuickCode Tag will vary, depending on which storefront page is being viewed.

become a master of the universe
All Template Packages must contain, at a minimum, a "universal" template titled universal.tpl. (Since it is what's used as the "backup" template to replace any other missing templates.)
 
Frequently Asked Questions

Question:
Does Modular Merchant still provide template packages that contain all the templates?

Answer:
By default, when a template package is installed, the only template that will be present in the package is the universal.tpl.

However, it is possible to populate additional templates into the template package if direct editing to them is needed, by using the Populate Templates tool in the Template Package Sandbox. Template packages can be searched for, downloaded and installed directly into your account from the [Design > Get Template Packages] page in your store's Administration Area.



Question:
Do my template packages have to either contain every template or just a universal one? Can I mix and match?

Answer:
There's no restriction, a template package can contain any number of templates! The only requirement is that every template package must contain a universal.tpl file. Other than that, the package may contain anywhere from zero to all of the other 35 templates. Just remember, if a storefront page's template isn't present, the universal template will be used to render that page's design and content instead.



Question:
Can I add or remove templates from a template package?

Answer:
Yes. One or more templates can be added to, or removed from, template packages at any time in the Template Package Sandbox, located in the Design section of the store's Administration Area.

After a template is deleted, the universal template will be used in its place when its corresponding storefront page is viewed.

The sandbox's Populate Templates tool can be used to add one or more missing templates to a template package. The Populate tool will start with a copy of the HTML code in the package's universal template. It will then replace the {UNIVERSAL-CONTENT} QuickCode Tag with the appropriate template-specific content, and then save the newly populated version of the template in the template package's directory. The new templates created with the Populate tool can then be edited independently, just like regular templates.
 
Footnotes

1. To hard boil the perfect egg, place six eggs in cold water and add 1 tablespoon salt. Bring the water to a boil, and boil for five minutes. Turn off the heat and let the eggs set in the water for 15 more minutes. Carefully pour out the hot water, keeping the eggs in the pot, then cover with cold running water for 5 minutes. For altitudes over 4000 feet, add two minutes boiling time and seven minutes hot setting time.

Powered by ModularKB