Introduction
AutoKB has a powerful template system that allows you to change the look and layout of your knowledge base. The template system provides an
easy way for you to edit the look of the knowledge base without having to edit a single line of PHP code. As long as you have a solid understanding
of HTML, you can easily modify the templates so that your knowledge base can integrate seamlessly into the rest of your website.
Control Panel Editing Interface
All changes to your templates will be made through the control panel. From the control panel menu, locate and click on the Edit Templates
link to access the built in template editor. AutoKB will load a page where you will be able to select which of the templates you want
to edit. Select the template you want to edit from drop down selection list, and press the Load Template button.
You will be returned to the same page, however now there will be a large text input box where you will edit the HTML code of the template.
The first time you do this, the text input box will contain AutoKB's default HTML. You can edit that HTML or paste your own HTML code into
this text input box. When you are satisfied with the changes you have made, press the Save Template button. This will save a copy of the
template and pre-compile the template so that the page can be rendered quickly when it is accessed.
Before Making Changes
Before you start making changes to the default HTML, it is recommended that you look it over and try to understand it. Seeing an example of how
the template system works should make it easier for you to create your own templates. It is also recommended that you add a few test articles
and glossary words to see how they are displayed with the default template.
Template Values
When you edit the templates you will notice in several places text that is surrounded by ## characters. For example, on the index_article.tpl template
(which is used when viewing an article in the knowledge base) the value ##Topic## appears. This value is a special value for the software which will
be replaced by the article's topic when the page is rendered. Because these are special values you should not use any text on your page that uses this
same format. If you do, it will be removed by the software before the page is rendered. Only recognized template values will be replaced by the software.
Some template values are valid only inside template sections (described further on in this document) and some are valid anywhere on the page except
inside template sections. The template values that are valid only inside template sections are called local template values. Those template values
that are valid anywhere except inside template sections are called global template values.
Now for a quick example. Suppose you are working on a template which has two valid template values, ##Date## and ##Time##.
You may then have the following HTML code somewhere in your template:
Today is ##Date## and the current time is ##Time##
Since ##Date## and ##Time## are valid template values, AutoKB will have already calculated the current date and time so they can be placed
in the template. When AutoKB parses the template, it will come across the ##Date## and ##Time## template values. Those two values will be
replaced by the date and time that AutoKB has calculated. Assuming AutoKB has calculated the date as January 1st, 2003 and the time as
7:00am, the following HTML would be generated based on your template:
Today is January 1st, 2003 and the current time is 7:00am
Further on in this document all of the valid template values for each template will be listed, along with a description of what they
will display when they are parsed and rendered by AutoKB.
Template Sections
Besides template values there are also template sections. A template section gives AutoKB information on what type of data should be displayed
in a certain section and how it should be displayed. Each of the template files have their own sections that you can use, and all of the available
template sections will be described in detail further on in this document.
Sections are defined in your template by an opening and closing tag. Each of the tags starts with an opening curly brace { and ends with a closing
curly brace }. For example, you might have a section that is named articles with an opening tag of {articles} and a closing tag of {/articles}. Note
that the closing tag is the same as the opening tag with the exception that a forward slash is placed before the section name. All sections must contain
both an opening tag and a closing tag or the template will not work properly.
Here is an example of what a section might look like, using the articles example:
{articles}
This text is contained within the section
{/articles}
Notice that the section opening and closing tags are on a line by themselves. This is required and failure to follow this format will result in templates
that do not work correctly. It is also possible to have nested sections, where one section is contained within another. Here is an example of that:
{articles}
This text is contained within the section
{noarticles}
This text is contained within the nested section
{/noarticles}
{/articles}
Notice that the nested section name is noarticles and it's opening and closing tags are completely contained within the articles section. Again, the
nested section's opening and closing tags are on a line by themselves.
Details on Each Template
Each of the templates used by the software has it's own set of valid template sections and values. This portion of the document will cover
each of the templates that you can edit, including their valid template sections and values. One template section can be used on any of the
templates, so it is covered first.
{include}
{/include}
This template section can be used to include the contents any file from your webspace into the template when it is rendered.
Simply place the full directory path to the file that you want to include inside this template section. You can also use a
virtual path that is relative to the directory that your knowledge base is installed in.
comment_added.tpl
This template is displayed to the user after they have added a comment to an article.
Global Template Values
##Article_ID## - The ID number of the article that this comment was added to
##Topic## - The topic of the article that this comment was added to
##Name## - The name that the user submitted for the comment
##Message## - The comment that the user submitted
Template Sections
{status}
{/status}
The status template section does nothing by itself, it must contain the nested approved and pending sections in order to have
any affect on the template. This template section has no valid template values.
{approved}
{/approved}
The approved template section should contain the HTML that will be displayed to the user if their comment has been automatically
approved and is now visible in the knowledge base. This must be nested inside the status template section.
This template section has no valid template values.
{pending}
{/pending}
The pending template section should contain the HTML that will be displayed to the user if their comment needs to be approved
before it will be displayed in the knowledge base. This must be nested inside the status template section.
This template section has no valid template values.
comment_main.tpl
This is the page that the users will see when they want to add a comment to an article
Global Template Values
##Article_ID## - The ID number of the article that this comment will be for
##Topic## - The topic of the article that this comment will be for
Template Sections
This template has no valid template sections
email_main.tpl
This is the page that the users will see when they want to e-mail this article to a friend
Global Template Values
##Article_ID## - The ID number of the article that the user wants to e-mail
##Topic## - The topic of the article that the user wants to e-mail
Template Sections
This template has no valid template sections
email_message.tpl
This is the e-mail message that will be sent when someone e-mails an article to their friend
Global Template Values
This template has no global template values
Template Sections
{subject}
{/subject}
This is the subject of the e-mail message that is being sent. This template section has no valid template values.
{message}
{/message}
This is the body of the e-mail message that is being sent. Valid template values for this section are:
##Name## - The name of the user that is sending the e-mail
##Topic## - The topic of the article that is being sent
##Article_URL## - The full URL to the article that is being sent
##KBase_URL## - The full URL to the main page of your knowledge base
{comment}
{/comment}
If the user supplied a comment you can use this section to define the text that will be included in the e-mail. If no comment was
provided, this section is ignored and not included in the e-mail message. This section must be nested within the message section.
Valid template values for this section are:
##Name## - The name of the user that is sending the e-mail
##Comments## - The comments that the user provided
email_sent.tpl
This is the page that the users will see after they have sent an e-mail to their friend
Global Template Values
##Article_ID## - The ID number of the article that the user e-mailed
##Topic## - The topic of the article that the user e-mailed
##Name## - The name of the user who sent the e-mail
##From## - The e-mail address of the user who sent the e-mail
##To## - The e-mail address that the e-mail message was sent to
##Comments## - The comments provided by the user, if any
Template Sections
This template has no valid template sections
glossary_main.tpl
This is the page that the users will see when viewing the glossary
Global Template Values
##Term## - The search term entered by the user, if any
##Start## - The starting point of the words displayed on the page
##End## - The ending point of the words displayed on the page
##Words## - The total number of words matching the user's search
Template Sections
{all}
{/all}
This section contains the HTML that should be displayed for the ALL link on the glossary page. The ALL link tells the glossary to display
all words in the glossary sorted alphbetically.
{viewing}
{/viewing}
This section contains the HTML that should be displayed for the ALL link on the glossary page when the user is currently viewing
all words. This is useful because there is no point to link to the ALL page when you are already viewing it. This must be nested
within the all section.
{letters}
{/letters}
This section will automatically display all of the letters of the English alphabet in order. You should include HTML in this section
so that users can click on each letter to view that section of the glossary. This section loops over all of the letters in the alphabet
and uses the HTML you have provided for each on of the letters. You only need to provide the HTML code for a single letter and the
software will use that repeatedly. Valid template values for this section are:
##Letter## - The current letter of the alphabet
{viewing}
{/viewing}
This section contains the HTML that should be displayed for the letter if it is the letter that is currently being viewed by the user.
This is useful because there is no point to link to the letter that the user is alredy viewing. It also gives a visual indication to
the user of what letter they are viewing. This must be nested within the letters section.
{delimiter}
{/delimiter}
This is the HTML code that you want to place between each letter. Because the software loops through the alphabet in the letters
section, you will likely want to separate them from each other so the user can easily pick the letter they want to view.
{prevpage}
{/prevpage}
This section will display a link to the previous page of search results if necessary. If the user is viewing the first page of results
the HTML in this section will not be displayed. Valid template values for this section are:
##Encoded_Term## - A URL encoded version of the search term suitable for use in a URL
##Letter## - The letter of the alphabet that the user is currently viewing, if any
##Prev## - The page number of the previous page
{nextpage}
{/nextpage}
This section will display a link to the next page of search results if necessary. If the user is viewing the last page of results or
there is only a single page of results, the HTML in this section will not be displayed. Valid template values for this section are:
##Encoded_Term## - A URL encoded version of the search term suitable for use in a URL
##Letter## - The letter of the alphabet that the user is currently viewing, if any
##Next## - The page number of the next page
{words}
{/words}
Use this section to display the glossary words that matched the user's search. The software will loop through each of the results using the
HTML in this section for each word that is displayed. You only need to include the HTML for a single word in this section; the software will
use that HTML repeatedly for each word that is displayed. Valid template values for this section are:
##Word## - The glossary word
##Definition## - The definition of the glossary word
{nowords}
{/nowords}
Use this section to specify the HTML that should be displayed if no words match the user's search. This must be nested within the words
template section. This template section has no valid template values.
index.css
This is the style sheet used by all of the templates listed in this section. There are no template values or template sections.
When you are modifying your template, you should modify this file if you want to make simple changes to the colors used in the
knowledge base. Changes made here will affect all of the templates.
index_article.tpl
This is the page that will display an article to the user
Global Template Values
##Topic## - The topic of the article
##Article## - The article itself
##Article_ID## - The ID number of the article
##Created## - The date and time that the article was created
##Updated## - The date and time that the article was last updated
##Views## - The number of times the article has been viewed
##Rating## - The average rating of the article
Template Sections
{categories}
{/categories}
This section will display all of the available categories. The software will loop through all of the categories, using the HTML from this section
repeatedly. You should only provide the HTML for a single category in this section. Valid template values for this section are:
##Category_ID## - The unique ID number assigned to the category
##Spaces## - A software defined value that will insert the necessary spaces so the category will be correctly offset from it's parent
##Name## - The name of the category
{categorypath}
{/categorypath}
Use this section to provide the HTML that will be used to display the full category that this article is located in. The software will display
the full category path by looping over the categories and sub-categories that must be traversed in order to get to the category that this article
is located in. Only include the HTML for a single category in this section, the software will use it repeatedly for each category. Valid
template values for this section are:
##Category_URL## - The full URL to the category page of the knowledge base
##Name## - The name of the category
{delimiter}
{/delimiter}
Use this section to specify the HTML that should be placed between each category in the category path. This must be nested within the
categorypath template section. This template section has no valid template values.
{related}
{/related}
Use this section to display this articles related articles. The related section does nothing by itself, you must use the hasrelated and norelated
nested sections to provide the HTML.
{hasrelated}
{/hasrelated}
Use this section to specify the HTML that should be used to display related articles. The software will loop through all of the related articles
and use this HTML repeatedly to display them. You should provide only the HTML for a single related article in this section. Valid
template values for this section are:
##Article_URL## - The full URL to the related article in the knowledge base
##Topic## - The topic of the related article
{norelated}
{/norelated}
Use this section to specify the HTML that should be displayed if this article has no related articles. This template section has no valid template values.
{comments}
{/comments}
Use this section to display the comments for this article. The comments section does nothing by itself, you must use the hascomments and nocomments nested
sections to provide the HTML.
{hascomments}
{/hascomments}
Use this section to specify the HTML that should be used to display this article's comments. The software will loop through all of the comments
and use this HTML repeatedly to display them. You should provide only the HTML for a single comment in this section. Valid
template values for this section are:
##Name## - The name of the user who submitted the comment
##Created_Date## - The date that the comment was submitted
##Created_Time## - The time of day that the comment was submitted
##Message## - The comment that the user submitted
{nocomments}
{/nocomments}
Use this section to specify the HTML that should be displayed if this article has no comments. This template section has no valid template values.
{rated}
{/rated}
Use this section to display some HTML to the user after they have rated an article. Valid template values for this section are:
##Rating## - The rating that the user gave the article
{notrecorded}
{/notrecorded}
If the user's rating was not recorded for some reason (they had already rated or their rating was outside the allowed range) the HTML in
this section will be displayed after the user tries to rate the article. This section must be nested in the rated section and has no valid
template values.
{attachments}
{/attachments}
Use this section to display the attachments for this article. The attachments section does nothing by itself, you must use the hasattachments
and noattachments nested sections to provide the HTML.
{hasattachments}
{/hasattachments}
Use this section to specify the HTML that should be used to display this article's attachments. The software will loop through all of the attachments
and use this HTML repeatedly to display them. You should provide only the HTML for a single attachment in this section. Valid
template values for this section are:
##Filename## - The filename of the attachment
##Attachment_URL## - The full URL to download the attachment
{noattachments}
{/noattachments}
Use this section to specify the HTML that should be displayed if this article has no attachments. This template section has no valid template values.
index_browse.tpl
This is the page that will be shown when the user is browsing the knowledge base by category
Global Template Values
##Start## - The starting point of the articles displayed on the page
##End## - The ending point of the articles displayed on the page
##Articles## - The total number of articles in the category they are viewing
Template Sections
{prevpage}
{/prevpage}
This section will display a link to the previous page of articles if necessary. If the user is viewing the first page of articles
the HTML in this section will not be displayed. Valid template values for this section are:
##Category_ID## - The unique ID number of the category the user is viewing
##Prev## - The page number of the previous page
{nextpage}
{/nextpage}
This section will display a link to the next page of articles if necessary. If the user is viewing the last page of articles or
there is only a single page of articles, the HTML in this section will not be displayed. Valid template values for this section are:
##Category_ID## - The unique ID number of the category the user is viewing
##Next## - The page number of the next page
{categories}
{/categories}
This section will display all of the available categories. The software will loop through all of the categories, using the HTML from this section
repeatedly. You should only provide the HTML for a single category in this section. Valid template values for this section are:
##Category_ID## - The unique ID number of the category
##Category_URL## - The full URL to the category page in the knowledge base
##Name## - The name of the category
##Spaces## - A software defined value that provides the necessary spaces so the category will be correctly offset from it's parent
##Offset## - A software defined value that provides the necessary pixels so the category will be correctly offset from it's parent
##Articles## - The number of articles in this category
{viewing}
{/viewing}
This section contains the HTML that should be displayed for the category when the user is currently viewing that category.
This is useful because there is no point to link to the category page when you are already viewing it. This must be nested
within the categories section. The same template values that are valid in the categories section are valid in this section.
{categorypath}
{/categorypath}
Use this section to provide the HTML that will be used to display the full category that the user is currently viewing. The software will display
the full category path by looping over the categories and sub-categories that must be traversed in order to get to the category that the user is
viewing. Only include the HTML for a single category in this section, the software will use it repeatedly for each category. Valid
template values for this section are:
##Category_URL## - The full URL to the category page of the knowledge base
##Name## - The name of the category
{delimiter}
{/delimiter}
Use this section to specify the HTML that should be placed between each category in the category path. This must be nested within the
categorypath template section. This template section has no valid template values.
{viewing}
{/viewing}
This section contains the HTML that should be displayed for the category when the user is currently viewing that category.
This is useful because there is no point to link to the category page when you are already viewing it. This must be nested
within the categories section. The same template values that are valid in the categorypath section are valid in this section.
{articles}
{/articles}
Use this section to display the articles in the category that is being browsed. The software will automatically loop through the articles
and use the HTML in this section repeatedly. You should only provide the HTML for a single article in this section. Valid
template values for this section are:
##Article_URL## - The full URL to the article in the knowledge base
##Topic## - The topic of the article
##Chopped_Article## - The first 80 characters of the article
##Category_Path## - The full path to the category this article is located in
{noarticles}
{/noarticles}
This is the HTML that will be displayed if there are no articles in this category. This template section has no valid template values.
{categorypath}
{/categorypath}
This is identical to the non-nested version of the categorypath section. The only difference is that the viewing nested section is not supported.
The delimiter nested section, however, is supported.
index_error.tpl
This is the page that the users will see if an error has occurred
Global Template Values
##Message## - This is the software generated message describing the error
Template Sections
This template has no valid template sections
index_main.tpl
This is identical to the index_browse.tpl template except that it does not display articles for a specific category.
Instead it displays the top 10 most viewed articles.
index_print.tpl
This is the page that the user will see if they want to print an article
Global Template Values
##Article_ID## - The unique ID number assigned to the article they are printing
##Article_URL## - The full URL to the article in the knowledge base
##Topic## - The topic of the article they are printing
##Article## - The article itself
Template Sections
{categorypath}
{/categorypath}
This is identical to the categorypath section of the index_browse.tpl template.
index_search.tpl
This is identical to the index_browse.tpl template except that it does not display articles for a specific category.
Instead it displays the articles that match the term the user searched for. The following differences should also be
noted:
A global template value ##Term## can be used to display the term they searched for.
The prevpage and nextpage sections support the ##Encoded_Term## template value which provides a URL encoded version of the search term.
suggest_added.tpl
This is the page that the user will see after their suggestion has been submitted
Global Template Values
##Email## - The e-mail address of the user who submitted the suggestion
##Category## - The category the user has suggested for their suggestion
##Suggestion## - The suggestion that was submitted
Template Sections
This template has no valid template sections
suggest_main.tpl
This is the page that the user will see after their suggestion has been submitted
Global Template Values
This template has no valid template values
Template Sections
{categories}
{/categories}
This is identical to the categories section of the index_browse.tpl template.