Go to the first, previous, next, last section, table of contents.
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.
Go to the first, previous, next, last section, table of contents.