Templates
Submitted Mark, May 26 2010 09:36 AM | Last updated May 07 2012 03:06 PM
There are several different types of templates:
One last note: if you are interested in creating a custom unique template (like we did for displaying links) you can click "Database Tag Help" when editing the template to get a popup that will help show you all of the available variables you can expect to access within your template. This is useful to confirm which field holds which values (i.e. what variable to use to display the title). The database tag help window will show you the variables available to all three templates.
- Page Templates
These allow you to create a structure which can be used throughout your pages. For example, many sites will use the same header and footer on all pages - you could create a template with this content to save you editing it for every page. - Database Templates
IP.Content uses database templates to display database content. For example, you will need to create a template which contains the structure of how a record should be displayed, and when a record is viewed, IP.Content will use this template. - Article Templates
These are like database templates, but for articles.
Page Templates
IP.Content allows the administrator to (optionally) create page templates that they can use to format multiple pages in a similar fashion. Most websites have a standard "wrapper" that all (or most) pages use, while only the main content area changes. IP.Content has all of the functionality built in for you to make use of this.
Using the IP.Board Wrapper
The first consideration you have to make is whether you want pages to be wrapped in the IP.Board standard wrapper (inheriting your normal skin output), or if you want to develop the pages from the ground up, without using the IPB wrapper. You can decide this on a per-page basis during the initial creation of the page, and later change it by clicking "Use Wizard" from the page editing form. You can also go to the IP.Content settings area and specify the default. If you find that most of your pages you do not use the IPB wrapper, you would want the default for this setting to be "off" to speed up page creation. Similarly, if you typically do use the IPB wrapper, you may want to turn this default setting "on" so you don't have to remember to select the option for every page you create.
If you use the IP.Board wrapper, your entire page (and template, if used) will be placed inside the basic IP.Board wrapper. This means the opening <html>, <head>, <body>, and other associated tags are already specified (as well as the same closing tags) and you should NOT specify these in your page template. Browser behavior with these structural tags duplicated is unpredictable.
Using a page template
When you create or edit a page, you can specify to use your own page template as well, which you create under the IP.Content Templates area. You can create one or two page templates, for instance, and then specify each page when you create the page to use the template. Doing this will allow you to ensure that all of your pages share the same template HTML code, giving a more consistent feel for your site.
You are not required to use page templates, and can create each and every page from scratch, if you prefer. The choice is yours.
Content editing method
Below the page template option when adding a new page, there is another option: Only edit page content?
As we pointed out previously, most sites have a similar wrapper throughout, and only the main content area changes. If you find yourself in this situation, you most likely will want to select "Yes" for this particular option. When you choose "Yes" for this option, you will be presented with a blank textarea box where you can specify the main content that you will want to display as your page. The template will be automatically inherited, and your content will be placed within the template where you have specified. The main benefit to this method is that if you later edit your page template (for instance, to add a search box to the top of the page), each and every page inheriting this template will automatically and immediately be updated.
You can, however, also choose "No" for this option if you require more fine-tuned control. When you select "No" for this option on the wizard, the textarea box will be pre-populated with the page template you select, and you will NOT inherit from the template in the future. This method would allow you to create a couple of generic page templates, for example, but then allow you to customize or change parts of those templates on a per-page basis, without having to keep copies of the generic templates elsewhere. The main downside to this method, however, is that if you edit any of your templates in the future, those changes will NOT be inherited in pages that use the template, but have selected "no" for this particular option.
Showing the page content in a template
When you create a page template, you will want to be sure that you specify where the content should show within the page template. The template tag help window will show you the proper tag to use. That tag is
{ccs special_tag="page_content"}
Going above and beyond
Page templates can be quite a powerful, time-saving feature as you can see here. However, there's even more that advanced users can make use of should they wish to. For instance, you may not be aware that IP.Content page templates are run through our skin system and are actually treated as a compiled skin file. That means template includes are functional within page templates. Putting this all together, you could, for example, create one page template for your "header", one for your "footer", and then two page templates for your structural layout. Then, in both of your structural layout templates, you would simply include the header and footer templates. Using this method means you can still have multiple templates for different areas of your site, but share the same header (and update only one header "template" to apply changes to every page throughout your site, regardless of which page template it uses).
Header (key: header_template)
<html> <head> This is the common header </title> <body>
Footer (key: footer_template)
</body> </html>
Page template
{parse template="template_header_template" group="ccs" params=""} <h1>Page template</h1> <div>{ccs special_tag="page_content"}</div> {parse template="template_footer_template" group="ccs" params=""}
Now, you'll note that when you do a template include, the group is "ccs" (i.e. for skin_ccs) and the template is "template_(template key)". Of course you don't have to make use of this functionality (nor are you restricted to including only IP.Content templates), but it is there for users who have a use for it.
(Be advised that you can NOT use a template include as above to include an IP.Content page template into an IP.Board skin template. While page templates use the IP.Board skin engine, they are stored and handled separately, and are not treated by IPB itself as a valid skin file)
As you can see, the page templates can be a great time-saver for sites looking to add many similar pages. We make use of page templates on our main website, and here in the resources area. They can also be a good abstraction tool. You can let copy editors simply add "pages" with the content that should be on the page, and let designers manage the page templates. The copy editors never need to look at the HTML structure that goes into creating the page, and the designers don't need to care what content will be on the page specifically.
If you have other good uses for page templates, please feel free to leave your comments and let us know!
Database Templates
When you add or edit a template in IP.Content 1.1.x, you must specify three database templates: Category, Listing and Display. By default, IP.Content 1.1.x comes with a generic copy of each of these templates, however you are able to create your own to suit your needs.
The basic premise behind the database templates is this: you may have one or more databases that should display identically, while at the same time you may have one or more databases that should display differently. To achieve this end goal, database templates are used so that you can customize how the content within each database is presented on a per-database level. You may optionally use the same generic default templates for each database you create, or you may optionally create different database templates for each database create, so that each database has it's own unique look. You may also, of course, mix and match (i.e. have 2 databases using one set of templates, and a third database using a second set of templates). - Category Template: The category template is used to display the categories when you first access the page the database is embedded into. This would be equivalent to the following page (as an example): http://community.inv...s/articles.html . It is important to note that if you do not create any categories within a database, this template will not be used.
- Listing Template: This is the template used when listing records within a given category (or, if you do not use categories within a given database, to list the records within the database). This template has the code in it to show the subcategories, if applicable, shows a listing of records, and shows the form at the bottom to filter/sort the records in a customizable manner.
- Display Template: This template is used to show an individual record within a database. It has the code in it necessary to display ratings and comments, as well as the record information.
One last note: if you are interested in creating a custom unique template (like we did for displaying links) you can click "Database Tag Help" when editing the template to get a popup that will help show you all of the available variables you can expect to access within your template. This is useful to confirm which field holds which values (i.e. what variable to use to display the title). The database tag help window will show you the variables available to all three templates.











3 Comments
<php> $this->myCustomCss = array('foo', 'bar'); </php> {parse template="template_header_template" group="ccs" params=""} <h1>Page template</h1> <div>{ccs special_tag="page_content"}</div> {parse template="template_footer_template" group="ccs" params=""}Where does one define the key for the template?
When you create a template you have the opportunity to specify the "Template Key" right on the form.