Difference between revisions of "Designing Output Templates"

From ActionApps Documentation
Jump to: navigation, search
(Special views (Calendar,RSS))
Line 10: Line 10:
 
<aafaq id=1714> ~ToDo: 1714 Where is the HTML</aafaq>
 
<aafaq id=1714> ~ToDo: 1714 Where is the HTML</aafaq>
  
== Special views (Calendar,RSS) ==
+
== Special views (Calendar,RSS,..) ==
 +
<aafaq id=1715>~ToDo: 1715 How to create a Calendar </aafaq>

Revision as of 19:15, 28 July 2005

Let's assume we have some data in the ActionApps slice. In this chapter, we'll look at how to present the data on the website, that means how to create a (single) web page which lists the data in the desired format and look. First, let's look briefly at which parts of ActionApps are responsible for generating the design:

Index View

~ToDo: Describe index view

Fultext View

~ToDo: Describe fulltext view 

Where can the design come from

Where is the HTML

The HTML for a typical APC-AA site can come from many places which can confuse people used to doing all their HTML in a single place.

Location What to put there
.shtml file static HTML that doesn't repeat, and is not changed often. Can be edited with any standard web editor by someone who has write permissions on the web server. The HTML has lines like <!--#include "/apc-aa/view.php3 --> (or apc-aa/slice.php3) to include a PHP file which will fetch information from the Slice's design.
Design section of the Slice This is used to list a range of items in a slice, or display a single item. Someone with Admin permission on the slice can go to apc-aa/admin -> Admin -> Views or apc-aa/admin -> Admin -> Display/Index or Display/Fulltext. HTML can be placed here associated with the top and bottom of a listing, with each item, and with groupings of items. The HTML includes alias such as _#HEADLINE
Aliases such as _#HEADLINE Each alias defines how to show a particular field, it does this by choosing a function (e.g. f_h) and parameters. For example _#HEADLINE is usually just output, while a Link might be output surrounded by <a href=" and ">. They can be edited by anyone with administrator priviliges on your slice by going to Admin->Fields->choose field ->Edit. A field can have several different ways of being output, for example a date could have aliases for both short (1/1/200) and long (1 January 2000) forms of output.
Functions such as f_h These define functions certain common ways fields are output. They are defined in the PHP code, and so have to be edited by developers, except that there is an extension function f_u that calls functions from apc-aa/include/usr_aliasfnc.php3, these can be written by anyone who understands PHP3.
Data Lastly of course, the HTML could be in specific fields in your data.

Exceptions:

  • You don't have to put a .shtml at the top - you can just use a more complex URL refering to apc-aa/slice.php3 or apc-aa/view.php3
  • You can include a view from within an alias by using the function f_v


Special views (Calendar,RSS,..)

How to create a Calendar

The AA now enable to create a Calendar. Events lasting for several days are supported, repeating events are not supported.

Usually three parts of a calendar view are needed. First, a table showing the days and perhaps some caption of events which happen. This is prepared by the calendar view type. Second, some select boxes to choose the year and the month. Prepare these in a .php3 page. Third, a list of events to be shown after clicking on a date. This may be done by a list view with the conditions set as explained further.

To put the view and the caption together, use a .shtml page --- an example of a very simple one is in doc/script/calendar.php3.

Calendar view

Create it by Admin - Views - Calendar - New. Two calendar types are available: Month List shows a month with days in one list under each other, Month Table shows a table with one row for each week. Some new aliases are defined:
  • _#CV_NUM_D is the number of the day (to be used in a day cell)
  • _#CV_NUM_M is the number of the month (to be used in a day cell, usually in an URL link)
  • _#CV_NUM_Y is the number of the year (to be used in a day cell, usually in an URL link)
  • _#CV_TST_1 time stamp of the current day at 0:00 (to be used in a condition)
  • _#CV_TST_2 time stamp of the next day at 0:00 (to be used in a condition)
New parameters to the view command are introduced: month and year. E.g.
set[301]=month-3&year-2002

The view setting are as follows:
  • Top HTML code must contain the <table> tag and may contain e.g. a table row with names of week days (Mon,Tue,...).
  • Bottom HTML code must contain the </table> tag.
  • Additional attribs to the TD event tag may e.g. set a background color to each event. If the alias _#COLOR___ contains a color, write bgcolor=_#COLOR___
  • Event format is the code for the Event description.
  • Start date field contains the event start date (must be filled!).
  • End date field contains the event end date (must be filled!).
  • Day cell top format For "Month List" calendar type it must begin with a <tr> tag. It contains a table cell tag with the day number, usually linked to an daily event list, e.g.
    <td><A href="calendar.shtml?vid=319&cmd[319]=c-1-_#CV_TST_2-2-_#CV_TST_1&month=_#CV_NUM_M&year=_#CV_NUM_Y&day=_#CV_NUM_D"><B>_#CV_NUM_D</B></A></td>

    The view settings cmd[319]=c-1-_#CV_TST_2-2-_#CV_TST_1 involve appropriate settings in the list view (no. 319 in my case) - see further. The month=_#CV_NUM_M&year=_#CV_NUM_Y&day=_#CV_NUM_D variables are used in the .php3 page to show the appropriate date - see the example in doc/example/calendar.php3
  • Day cell bottom format for "Month List" it must end with </tr>
  • Empty day cell top format usually the same as Day cell top format, but without the link to the event list
  • Condition 1,2,3 you may use conditions with the calendar, e.g. to view only events of some type

Year and month selectboxes

These may be created by a .php3 script. An example of one is in doc/script/calendar.php3. The script is commented

List of events

An ordinary view of the type "Item listing" will do. You must set two conditions. The first condition must be "Start date <" where Start date is the name of the field containing event start date, the second must be "End date >=" where End date is the name of the field containing event end date.

The conditions are controlled by the command cmd[319]=c-1-_#CV_TST_2-2-_#CV_TST_1 described above.