[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This chapter will explain the most common usage of Catalog using an example set of catalogs created when you installed the product. You will not have to create a catalog by yourself. Everything is ready to use and we will only comment what have been done. You should sequentially read this chapter since concepts are introduced in each section and are needed to understand the following section.
Ideally the example provided with the Catalog distribution will allow you to build your own catalogs in a few cut and paste operations, without the need to fully read and understand the reference documentation.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
In the example used in this chapter, the urldemo table contains the data used in all the catalogs. Since your own application is likely to require a different kind of data you will have to create your own table.
A few requirements must be met when creating a table that will be used by catalogs (thematic, alphabetical or chronological).
create table urldemo ( ... rowid int autoincrement, ... unique urldemo1 (rowid) ); |
Catalog tables
.
If you're not sure how to create a new table, please refer to the MySQL documentation. If you want to do it quick and dirty you can guess from the table creation listed in the Catalog tables chapter.
At present we will use the urldemo table, you don't have to worry about creating a new table.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
When Catalog is installed, it builds an example database and copies two catalog
configuration profiles. An HTML page gives access to the example and is installed in the
same directory as the documentation (HTMLDIR when Catalog is installed).
If you've installed the documentation in the
HTMLDIR/Catalog/
directory,
the URL http://www.mymachine.com/Catalog/ will display the following page:
The admin configuration is stored in a subdirectory of the cgi-bin directory (CGIDIR when Catalog is installed). It customizes the administration interface of the catalogs.
The browse configuration is stored in a subdirectory of the cgi-bin directory. It customizes the user view of the catalogs.
The resources database is a set of URLs, stored in the urldemo table that have the following structure:
create table urldemo ( # # Table management information # rowid int auto_increment not null, created datetime not null, modified timestamp not null, info enum ('active', 'inactive') default 'active', url char(128), comment char(255), unique cdemo1 (rowid) ) |
The rowid member and the cdemo1 index are mandatory. The url field stores the URL of a WEB site, the comment field stores a comment that shortly explains the purpose of the WEB site, the created field is the date of the insertion of the record in the database.
The URLs found in the urldemo table relate to full text indexing and searching the WEB. Based on this table we have created three catalogs:
It must be clearly understood that any number of catalog can be created for a given table (urldemo for instance) with no need to duplicate the data of this table. The catalogs are maintained using administrative tables that are not directly related to the table containing the records classified.
The example database created is named catalog_example and is loaded with three catalogs (urlcatalog, urldate and urlalpha) based on the urldemo table. The database may be dropped if you want to get rid of it at a later time with the following MySQL instruction:
drop database catalog_example; |
In short the example is installed in the following files/bases:
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Using the example entry point (HTML page located in
http://www.mymachine.com/Catalog/index.html), you can quickly browse
the example provided. The Control panel
link shows that three catalogs exist, as displayed
in the following figure:
The urldate catalog shows the urldemo records in the order in which they have been created (created field). The urlalpha catalog display an alphabetical index of the records in the urldemo table, based on the comment field. The urlcatalog catalog classifies the URLs in a thematic tree. If you click on the browse link next to the name of each catalog, you will be able to see what it looks like. When using these links, no interface customization is active : you see the display using all the default values and templates. The following figure shows the display of the /Directory category of the urlcatalog catalog.
You can also click on the edit button for the urlcatalog catalog to see the administration interface that allows you to create categories, insert records etc.
Going back to the example entry point (HTML page located in http://www.mymachine.com/Catalog/index.html), you will have access to a customized version of the urlcatalog catalog administration interface thru the link Edit URL catalog. You can compare the display with the non customized version for the /Directory category, as shown in the following figure:
The example entry point (HTML page located in http://www.mymachine.com/Catalog/index.html) then shows links to access the customized user view for the three catalogs (the Browse URL catalog (urlcatalog), Chronological history of the URL catalog (urldate) and Alphabetical URL catalog (urlalpha) links). You can compare them with what you saw when clicking on the browse links in the control panel.
The following sections will explain how to configure Catalog to achieve these effects. This is mostly a simple process that requires to modify some template HTML files.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
When the urlcatalog was created it was bound to the urldemo table. In addition, the order of the urldemo records displayed in a given category was set to ascending lexicographic order on the comment field. The following figure shows the complete configuration of the catalog (you can access it by clicking on the catalog name in the the control panel):
The urldate and urlalpha catalogs were configured in the same way.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Our purpose is to understand how the template for the administration of urlcatalog was modified to display the urldemo records in a user friendly way. This is the only customization performed for the administration but it is a crucial one. Without customization, the records are displayed in this fashion:
We want them to be displayed in this fashion instead:
The cedit.html template is used to display the current category in the administration interface. The template files are simple HTML files used by the cgi-bin to display their results. Special markers are detected and allow the cgi-bin to:
The _NAME_ tags (always in uppercase, surrounded by underscores) are replaced by values. The HTML comments that look like <!-- start entry --> and <!-- end entry --> define parts of the template that may be included conditionally or repeated to display a list.
For instance, in the following cedit.html template, the part enclosed between <!-- start categories --> and <!-- end categories --> will only be included if the displayed category has at least one sub category. Otherwise it will be completely omitted.
It is therefore very important to take great care not to remove the HTML comments, unless you know exactly what your are doing : they are used to display the results of the cgi-bin.
Here is a commented version of the default cedit.html template:
<title>Edit category _CATEGORY_</title> <center><h3><font color=red>_COMMENT_</font></h3></center> This is a form to search the catalog <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> These are buttons to perform actions on the category <h3>Edit category _CATEGORY_</h3> <a href='_CENTRYINSERT_'><img src=_HTMLPATH_/images/new.png alt='Insert a new record and link it to this category' border=0></a> <a href='_CENTRYSELECT_'><img src=_HTMLPATH_/images/link.png alt='Link an existing record to this category' border=0></a> <a href='_CATEGORYINSERT_'><img src=_HTMLPATH_/images/open.png alt='Create a sub category' border=0></a> <a href='_CATEGORYSYMLINK_'><img src=_HTMLPATH_/images/plus.png alt='Create a symbolic link to another category' border=0></a> <a href='_CONTROLPANEL_'><img src=_HTMLPATH_/images/control.png alt='Control panel' border=0></a> <p> <p> _PATH_ <p> This part is only shown if there are sub categories <!-- start categories --> <h3>Sub categories</h3> <table> <!-- params 'style' => 'table', 'columns' => 2 --> <!-- start row --> <tr> <!-- start entry --> <td> _LINKS_ <a href='_URL_'>_NAME_</a> (_COUNT_) </td> <!-- end entry --> </tr> <!-- end row --> </table> <!-- end categories --> <p> Display the records in this category <h3>Records in this category</h3> <!-- start entry --> <table border=1><tr><td>_LINKS_</td> _DEFAULTROW_</tr></table> <p> <!-- end entry --> This part is only shown if there is more than one page of records (page length is 10 records) <!-- start pager --> Number of pages _MAXPAGES_ <p> _PAGES_ <!-- end pager --> |
Since we want to change the display of the records, we only have to modify the relevant portion of the template, that is:
<h3>Records in this category</h3> <!-- start entry --> <table border=1><tr><td>_LINKS_</td> _DEFAULTROW_</tr></table> <p> <!-- end entry --> |
The entry part (delimited by the <!-- start entry --> and <!-- end entry --> HTML comments) will be repeated for each record in the category. We want to preserve the _LINKS_ tag that displays the buttons to perform actions on the record (remove, unlink and edit). But we want to change _DEFAULTROW_ to display only the fields of interest. The values of the fields of the urldemo table for the displayed record are available with the following tags : _URL_, _COMMENT_ and _CREATED_. The rationale of the tag substitution when a record is displayed is quite simple: each field name of the record is translated to uppercase and surrounded by underscores. This substitution is done automatically: there is no need to explicitly map the field names to tag names. This is very convenient when you add a new field to the records: the new fields can be displayed by including a new tag matching the field name in the template file.
In addition, a variation of the value is available by appending the -QUOTED string to the field name. This variation replaces HTML reserved characters such as quote (') or double quote (") by the appropriate HTML elements. This is useful to include a value in quotes, for instance. Here is the modified template part:
<!-- start entry --> <table><tr><td>_LINKS_</td> <td> <dt><a href='_URL-QUOTED_'>_COMMENT_</a> <dd> <a href='_URL-QUOTED_'>_URL_</a> <dd> <i><font size=-1>Created _CREATED_</font></i><br> </td></tr></table> <p> <!-- end entry --> |
Note that we have used _URL-QUOTED_ instead of _URL_ in the href instruction. The record layout is now exactly what we expect.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
We have modified the cedit.html template and now we would like Catalog to use it instead of the default template. The simplest method would be to create a file named cedit.html in the cgi-bin/admin directory. The default templates used by Catalog are included in the code of the application, therefore you will not find a cedit.html file anywhere. You will have to create it, copying it from the example or from this documentation. When the Catalog cgi-bin executes, it looks for templates in it's current working directory which is the cgi-bin directory, at least if you're using Apache.
This method is not suitable for us because we want (for the sake of the demonstration) to keep the default cedit.html and add a new one that would be activated only if we ask for it. This is achieved very simply by the use of the style cgi-bin parameter and the templates.conf configuration file.
What happens if you call the cgi-bin with an additional argument style=urlcatalog (you will see that the link Edit URL catalog in the example HTML entry point has this parameter) ? When the cgi-bin looks for a specific template (cedit.html in our case), it first searches the templates.conf file for a renaming instruction. For instance, in the template.conf file of the example (CGIDIR/admin/templates.conf) you can see these lines:
# # Catalog customization # urlcatalog # # Catalog editing # cedit.html = urlcatalog_cedit.html # # Search results # csearch.html = urlcatalog_csearch.html end |
This must be understood as : if the style is urlcatalog then use urlcatalog_cedit.html template instead of the default cedit.html. We should therefore create a urlcatalog_cedit.html file and copy the modified template HTML code in it.
In short, the modified cedit.html template is put in the urlcatalog_cedit.html file and cedit.html is mapped to urlcatalog_cedit.html for the urlcatalog style in the templates.conf file.
We have covered all the actions necessary to customize the administration interface of urlcatalog as shown in the example. We will now explain how to customize the user view of the catalog.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Now that the browsing interface for urlcatalog is customized, we still have to customize the search result display so that the records are displayed in the same way. The default template used to display the search results is csearch.html and contains:
<title>Search results for _TEXT_</title> <center> <form action=_SCRIPT_ method=POST> _HIDDEN_ <input type=text size=40 name=text value='_TEXT-QUOTED_'> <input type=submit value='search'><br> _WHAT-MENU_ </form> </center> <!-- start categories --> <center>Categories matching <b>_TEXT_</b> (_COUNT_)</center> <ul> <!-- start entry --> <li> <a href=_URL_>_PATHNAME_</a> <!-- end entry --> </ul> <!-- start pager --> Number of pages _MAXPAGES_ <p> _PAGES_ <!-- end pager --> <!-- end categories --> <!-- start nocategories --> <center>No category matches the search criterion</center> <!-- end nocategories --> <!-- start records --> <center>Records matching <b>_TEXT_</b> (_COUNT_)</center> <table border=1> <!-- start entry --> <!-- start category --> <tr><td colspan=20><a href=_URL_>_PATHNAME_</a></td></tr> <!-- end category --> <tr>_DEFAULTROW_</tr> <!-- end entry --> </table> <!-- start pager --> Number of pages _MAXPAGES_ <p> _PAGES_ <!-- end pager --> <!-- end records --> <!-- start norecords --> <center>No record matches the search criterion</center> <!-- end norecords --> |
This template is hairy because it contains many alternatives that define the HTML code to display:
Assuming that we search for records in the example database, the default display looks like this:
To customize the records display we only have to change the records part to duplicate what was done in the cbrowse.html template. You will notice that the entry part have a sub part named category:
<!-- start records --> <center>Records matching <b>_TEXT_</b> (_COUNT_)</center> <dl> <!-- start entry --> Sub part of entry that only shows once for a given category <!-- start category --> <p> <dt><b>Category</b> <a href=_URL_>_PATHNAME_</a> <!-- end category --> <p> <dt><a href='_URL-QUOTED_'>_COMMENT_</a> <dd> <a href='_URL-QUOTED_'>_URL_</a> <dd> <i><font size=-1>Created _CREATED_</font></i><br> <!-- end entry --> </dl> <!-- start pager --> Number of pages _MAXPAGES_ <p> _PAGES_ <!-- end pager --> <!-- end records --> |
This subpart must always be in the entry part. It will be displayed to show the category of the displayed record each time the category changes. Since the search results are sorted to group the records in the same category together, this will prevent showing the category name multiple times.
To continue with the renaming scheme used in the previous section we re-map csearch.html into urlcatalog_csearch.html in the templates.conf file.
# # 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 |
The search results when searching for www is now:
At this point we have covered all the operations needed to customize the user view of the urlcatalog thematic catalog as shown when clicking on the Browse URL catalog (urlcatalog) link in the example HTML entry point. By defining a new style you could create a new display. All we needed to implement this customization are four files : templates.conf, urlcatalog_csearch.html, urlcatalog_cbrowse_root.html and urlcatalog_cbrowse.html.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The urldate catalog displays the entries of the table urldemo in chronological order. Using the browse link in the control panel, you will see the following screen:
The default display of a chronologically ordered catalog contains a calendar. Only the days for which at least a record exists are shown. The records themselves are shown in the last part of the display. The years, months and days of the calendar are hypertext links that will only display the corresponding year, month or day.
The template used is cdate_default.html. It contains two logical parts : the display of the calendar and the display of the records.
<html> <body bgcolor=#ffffff> <title>Date catalog</title> Display the calendar <!-- start years --> <a href=_YEARLINK_>_YEARFORMATED_</a> (_COUNT_) <blockquote> <!-- start months --> <!-- params format => '%M' --> <a href=_MONTHLINK_>_MONTHFORMATED_</a> (_COUNT_) <ul> <!-- start days --> <!-- params format => '%W, %d' --> <li> <a href=_DAYLINK_>_DAYFORMATED_</a> (_COUNT_) <!-- end days --> </ul> <!-- end months --> </blockquote> <!-- end years --> Display the records <!-- start records --> Records <!-- start entry --> <p> <table border=1><tr>_DEFAULTROW_<tr></table> <!-- end entry --> <!-- start pager --> Number of pages _MAXPAGES_ <p> _PAGES_ <!-- end pager --> <!-- end records --> </html> |
The part of the template that displays the records is identical to the cbrowse.html or csearch.html templates. It is wrapped in the records part. If the records part is omitted, only the calendar will be displayed.
The part of the template that displays the calendar contains three
nested parts : days is included in months, itself
included in years. If the chronological display is required
without specifying a specific time interval, all the records are taken
in account. Thru the use of the date cgi-bin parameter, however, it is
possible to require that the cgi-bin only displays a given time interval.
For instance, if date is set to 1999
, it will only
consider the records of year 1999. If the date is set to 199902
it will only consider the records of February 1999.
If the date is set to 19990219
it will only consider the records of February, 19 1999. Here is a display
for this specific day:
We could customize the record part and keep the calendar in this format. This is the simple solution if you're in a hurry. To further demonstrate the customization of the chronological display we will show how to configure a different display according to the time interval. We want a different display when the time interval is:
As you can see on the figures above, the records are only displayed when the time interval is limited to a specific day. In all other cases only the calendar is shown. If the time interval is not bounded, only the years are displayed. If the time interval is limited to a specific year, only the months of the year are displayed. If the time interval is limited to a specific month, only the days of this month are displayed. On top of the display, hypertext links allow to widen the time interval.
The first thing to understand is how we differentiate the templates used. By default only cdate_default.html is used but we want to use four different templates for unbounded, year, month and day. This is achieve by using the template cgi-bin parameter. For instance, if the chronological display is called with
template=year |
then it will use the template cdate_year.html instead of cdate_default.html.
Let's start with the customization of cdate_default.html. Here is the customized template:
<html> <body bgcolor=#ffffff> <title>Chronological history of the URL catalog</title> <center><h3>Chronological history of the URL catalog</h3></center> <ul> <!-- start years --> <li> <a href=_YEARLINK_&template=year>_YEARFORMATED_</a> (_COUNT_) <!-- end years --> </ul> </html> |
The records part has been removed because we don't want to display them. The months and days parts of the years part have been removed because we don't want to go into details in this calendar. At this point the customization is really simple since we only had to remove parts to get a list of years. Each year is associated with a hypertext link (_YEARLINK_) that leads to the chronological display limited to the current year. We have appended the &template=year parameter to this tag so that the cdate_year.html is used instead of cdate_default.html.
Let's now configure the cdate_year.html template. Here is the customized template:
<html> <body bgcolor=#ffffff> <!-- start years --> <title>URL catalog in _YEARFORMATED_</title> <center> [ <a href=_SCRIPT_?name=urldate&context=cbrowse>Show all years</a> ] <h3>URL catalog in _YEARFORMATED_</h3> </center> <ul> <!-- start months --> <!-- params format => '%M' --> <li> <a href=_MONTHLINK_&template=month>_MONTHFORMATED_</a> (_COUNT_) <!-- end months --> </ul> <!-- end years --> </html> |
As for cdate_default.html, we have removed the parts that are not wanted : records and days since we only want to show the months of the year. In order to show the current year in the title we had to move the title (<title>) inside the years part. This is necessary because the _YEARFORMATED_ is only substituted in the years part. Since we know that this template will only be used for a specific year, there is not risk that the title be repeated more than once.
In the months part we use the same method as in cdate_default.html to force the usage of the cdate_month.html template when following the hypertext link to a specific month : we append &template=month.
One more trick is used to control the format of the _MONTHFORMATED_ tag. By default _MONTHFORMATED_ is substituted with the English name of the month followed by the year in four digit format (February 1999, for instance). However, since we clearly show the year in the title there is no need to repeat it for every month. The <!-- params format => '%M' --> comment in the months part controls the format of the _MONTHFORMATED_ tag. The string in single quotes is a MySQL date format specification (more information may be found in the MySQL date_format function documentation). The %M says that we only want the name of the month. The same format control method applies to the _YEARFORMATED_ and _DAYFORMATED_ tags.
Let's now configure the cdate_month.html template. Here is the customized template:
<html> <body bgcolor=#ffffff> <!-- start years --> <center> [ <a href=_SCRIPT_?name=urldate&context=cbrowse>Show all years</a> | <a href=_YEARLINK_&template=year>Months of _YEARFORMATED_</a> ] <!-- start months --> <!-- params format => '%M %Y' --> <h3>URL catalog in _MONTHFORMATED_</h3> <title>URL catalog in _MONTHFORMATED_</title> </center> <ul> <!-- start days --> <!-- params format => '%W, %d' --> <li> <a href=_DAYLINK_&template=day>_DAYFORMATED_</a> (_COUNT_) <!-- end days --> </ul> <!-- end months --> <!-- end years --> </html> |
There is no new concept in this template. The title (<title>) has been moved to the months part to show the current month using _MONTHFORMATED_ because this tag is only substituted in the months part. It's a bit strange to put the title so far in the HTML code but that's the only way to do it.
The list of links on top of the page now contain a link to display all the months of the year.
Lastly, the cdate_day.html template is built as follows:
<html> <body bgcolor=#ffffff> <!-- start years --> <center> [ <a href=_SCRIPT_?name=urldate&context=cbrowse>Show all years</a> | <a href=_YEARLINK_&template=year>Months of _YEARFORMATED_</a> | <!-- start months --> <!-- params format => '%M %Y' --> <a href=_MONTHLINK_&template=month>Days of _MONTHFORMATED_</a> ] <!-- start days --> <!-- params format => '%W, %d %M %Y' --> <h3>URL catalog _DAYFORMATED_</h3> <title>URL catalog _DAYFORMATED_</title> </center> <!-- end days --> <!-- end months --> <!-- end years --> <!-- start records --> <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> <!-- start pager --> <center> Number of pages _MAXPAGES_ <p> _PAGES_ </center> <!-- end pager --> <!-- end records --> </html> |
We now see the records part which looks exactly the same as in the cbrowse.html template.
We are finished with the customization of the chronological catalog. This method allows you to exactly controls the display while retaining a very simple default method.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The urlalpha catalog displays the entries of the table urldemo in alphabetical order, based on the comment field. Using the browse link in the control panel, you will see the following screen:
Each letter and digit is shown. If there is at least one record for which the comment field starts with a specific letter (case insensitive), the letter becomes an hypertext link and the number of records is appended. If there is no record for which the comment field starts with a specific letter, the letter alone is shown.
When you click on a letter, the following screen is shown:
Two templates are used : calpha_root.html for the first page and calpha.html to display a specific letter.
The default calpha_root.html template is as follows:
<title>Alphabetical Navigation</title> <h3>Alphabetical Navigation</h3> _A_ _B_ _C_ _D_ _E_ _F_ _G_ _H_ _I_ _J_ _K_ _L_ <p> _M_ _N_ _O_ _P_ _Q_ _R_ _S_ _T_ _U_ _V_ _W_ _X_ <p> _Y_ _Z_ _0_ _1_ _2_ _3_ _4_ _5_ _6_ _7_ _8_ _9_ <p> |
What we want is a nice GIF for each letter instead of the ugly text and that the GIF files used be different (grayed) if there are no records for a specific letter. In short we want this:
The modified template (calpha_root.html) is quite long and we only show a few relevant lines:
<body bgcolor=#ffffff> <title>Alphabetical URL catalog</title> <h3>Alphabetical URL catalog</h3> <table border=1> <tr> <td> <a href=_AURL_> <img src=_HTMLPATH_/images/letter_ALETTER_.png border=0> </a> <font size=-1>_ACOUNT_</font> </td> <td> <a href=_BURL_> <img src=_HTMLPATH_/images/letter_BLETTER_.png border=0> </a> <font size=-1>_BCOUNT_</font> </td> . . . </tr> </table> |
We have done two things : put the letters in a table and expand the default _A_ style tags. By default these tags are replaced by an hypertext link if appropriate. Since we want to show images, we have to control the expansion of the hypertext link. For this purpose we have three tags:
The lines specifying the display for one letter must be duplicated for each letter. Note that we use the _HTMLPATH_ tag to locate the images installed by Catalog. If you are using your own GIF file you will not need this tag.
The customization of the page displaying the records for a specific letter (calpha.html) is much simpler. The default template is as follows:
<title>Alphabetical Navigation _LETTER_</title> <h3>Alphabetical Navigation _LETTER_</h3> <table border=1> <!-- start entry --> <tr>_DEFAULTROW_</tr> <!-- end entry --> </table> <!-- start pager --> Number of pages _MAXPAGES_ <p> _PAGES_ <!-- end pager --> |
It contains a part that should now be familiar (entry) to display the records. We modify it to be compliant with the templates created so far:
<body bgcolor=#ffffff> <title>URL catalog letter _LETTER_</title> <h3>URL catalog letter _LETTER_</h3> <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> <!-- start pager --> Number of pages _MAXPAGES_ <p> _PAGES_ <!-- end pager --> |
Note that the _LETTER_ tag is substituted with the letter being displayed, in uppercase. It may be used to display a GIF file, for instance.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
In this chapter we have focused on the definition of the catalogs and the customization of the user interface. We have only shown how to customize the record layout for the administration of a thematic catalog. You will find that the reference chapters list all the templates used in by the administration interface of Catalog. You can modify all of them to fit your needs.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |