Custom Page Templates: Page Title and Page Name
This example custom page template probably won't win any awards for design excellence, but it can serve as an introduction to how HTML tags and custom template tags are used together in a template. Notice these parts of the template:
- A page template must start with [-- DEFINE PAGE --] and it must end with [-- END_DEFINE PAGE --]. (Note that the link for a page is defined before the [-- DEFINE PAGE --] tag, but that isn't shown in this example.)
- The opening <html> and closing </html> tags are inside the [-- DEFINE PAGE --] and [-- END_DEFINE PAGE --] tags.
- When ShopSite is building this page (during a Publish operation) and it comes across a custom template tag, such as the [-- PAGE.Name --] tag, it looks to see what the merchant entered as the name for the page and replaces the tag with that text. All custom template tags that refer to page or product information work the same way.
- You can use a custom template tag more than once per page. This example uses the [-- PAGE.Name --] tag twice.
- The merchant might put some HTML tags in the page name field (such as <b></b>). That's fine for displaying the name on the page, but the HTML <title> tag does not allow HTML formatting. For those situations, use the Remove_HTML parameter with the custom template tag to strip any HTML tags out of the field.
Page Title and Name Example Page Template Resulting Page
Example Page Template with IF Tags
You can add flexibility to your template by using [-- IF --] tags. You can test whether the merchant wants a certain field displayed, and whether fields have values. For example, the merchant can choose to not display the page name. Likewise, if the page name field is empty, it would not work well in the <title> tag. Here is the same example as above, but now it tests for these possibilities.
- For the <title> tag, the code tests to see if the page name field has a value. If not the store name is used instead.
- Before inserting the page name, the code tests to see if the merchant wants the page name displayed.