Go to the first, previous, next, last section, table of contents.
The basic concepts of template customization have been covered in the previous sections, while explaining how the administration interface was modified to show a better display of the records. We will now explain how the user view of the catalog urlcatalog was modified to display as shown in the following figures:
There are two differences between the administration interface for at thematic catalog and its user view:
The display of the top level category uses the cbrowse_root.html template and all other categories are displayed using the cbrowse.html template. This was done to allow a different display for the top level category because it is often needed. The default cbrowse_root.html and cbrowse.html are almost identical.
Here is the default cbrowse_root.html:
<title>Root</title> <center> <form action=_SCRIPT_ method=POST> <input type=hidden name=name value=_NAME_> <input type=hidden name=context value=csearch> <input type=hidden name=mode value=_CONTEXT_> <input type=text size=40 name=text value='_TEXT-QUOTED_'> <input type=submit value='search'><br> </form> </center> <h3>Root</h3> <!-- start categories --> <h3>Sub categories</h3> <ul> <!-- start entry --> <li> <a href='_URL_'>_NAME_</a> (_COUNT_) <!-- end entry --> </ul> <!-- end categories --> <p> <!-- start entry --> <p> <table border=1><tr>_DEFAULTROW_<tr></table> <!-- end entry --> <!-- start pager --> Number of pages _MAXPAGES_ <p> _PAGES_ <!-- end pager -->
In the example database we know that no records will be displayed at the top level because we will never insert a record in the top level category. Therefore we can remove the part of the template used to display records (starting from the <!-- end categories --> comment up to the end of the template).
Instead of displaying the categories using a bullet list, we want to display them as a two columns table. We want
instead of
We will have to modify the part of the template that is between <!-- start categories --> and <!-- end categories -->. Within this part there is a nested part delimited by <!-- start entry --> and <!-- end entry --> that is repeated for each sub category of the top level category (in the same way the records are displayed).
Obviously this does not allow us to display a two columns table. We have to substitute the entry part with something else. Fortunately, the row part is precisely designed for this purpose. Here is the final result:
<body bgcolor=#ffffff> <title>The Senga Resources Catalog</title> <center><h3>The Senga Resources Catalog</h3></center> <hr> <center> <form action=_SCRIPT_ method=POST> <input type=hidden name=name value=_NAME_> <input type=hidden name=context value=csearch> <input type=hidden name=mode value=_CONTEXT_> <input type=text size=40 name=text value='_TEXT-QUOTED_'> <input type=submit value='search'><br> </form> <hr> <!-- start categories --> <table> <!-- params 'style' => 'table', 'columns' => 2 --> <!-- start row --> <tr> <!-- start entry --> <td> <b><a href='_URL_'>_NAME_</a></b> (_COUNT_) </td> <!-- end entry --> </tr> <!-- end row --> </table> <!-- end categories --> </center>
We have substituted the <ul> with a <table> to start the table. The comment <!-- params 'style' => 'table', 'columns' => 2 --> instructs the display mechanism that we will use a table instead of a list ('style' => 'table') and that this table will have two columns ('columns' => 2). When this declaration is present we can wrap the entry part with a row part that will only be repeated every two columns. We are finished with the cbrowse_root.html template.
Now we want to customize the cbrowse.html template to display the categories in the same fashion and to display the records as defined when customizing the administration interface in the previous sections. The only noticeable detail is that the records are not displayed in a table but in a <dl>. The table was needed to correctly display the actions buttons in the administration interface but is not needed here because we do not show them. Here is the modified cbrowse.html template:
<body bgcolor=#ffffff> <title>_CATEGORY_</title> <center> <b>Category</b> _PATH_ <p> <form action=_SCRIPT_ method=POST> <input type=hidden name=name value=_NAME_> <input type=hidden name=context value=csearch> <input type=hidden name=mode value=_CONTEXT_> <input type=text size=40 name=text value='_TEXT-QUOTED_'> <input type=submit value='search'><br> </form> </center> <!-- start categories --> <center> <table> <!-- params 'style' => 'table', 'columns' => 2 --> <!-- start row --> <tr> <!-- start entry --> <td> <b><a href='_URL_'>_NAME_</a></b> (_COUNT_) </td> <!-- end entry --> </tr> <!-- end row --> </table> </center> <!-- end categories --> <dl> <!-- start entry --> <dt><a href='_URL-QUOTED_'>_COMMENT_</a> <dd> <a href='_URL-QUOTED_'>_URL_</a> <dd> <i><font size=-1>Created _CREATED_</font></i><br> <p> <!-- end entry --> </dl> <center> <!-- start pager --> Number of pages _MAXPAGES_ <p> _PAGES_ <!-- end pager --> </center>
Since we want to preserve the default display we will use the templates.conf file to re-map the cbrowse_root.html and cbrowse.html default templates when the style urlcatalog is activated. We will modify the templates.conf file located in CGIDIR/browse/templates.conf (instead of CGIDIR/admin/templates.conf for the administration interface) as follows:
# # Templates system configuration # style # # Catalog customization # urlcatalog # # Search results # csearch.html = urlcatalog_csearch.html # # Root of Catalog browsing # cbrowse_root.html = urlcatalog_cbrowse_root.html # # Pages of Catalog browsing # cbrowse.html = urlcatalog_cbrowse.html end end
Go to the first, previous, next, last section, table of contents.