Here we give an overview of the fmt language. For a general overview
of this system, see REDME. Also you'll probably want to use the
compiled fmt's which contains support for even more tags described in
REDAME.compiled_fmt.
General
-------
The fmt language used to specify how the data in the database should
be presented. It works in a template like way with a html like format,
and it can be specified on a PostSet, Post or Fld level (See the
DBIx::HTMLView::PostSet DBIx::HTMLView::Post or DBIx::HTMLView::Fld
respectivly).
It works by replacing the fld tags with data from the database. All it
knows of is it's own tags, which means that they can be placed inside
other tags in a HTML file and still be replaced with the correct
value. If you for example have the string:
then and will be replaced with their corresponding
values. The tags currently recogniced is:
- Inserts the special variable name
- Inserts the fld name view with the default fmt
... - Inserts the fld name view with the fmt string ...
... - Repeats ... for every post viewed
... - Evals the string ... and inserts it returnvalue
The tags can be place anywhere while the use of the others
depend on what the fmt string is suposed to represent (eg Fld, Post or
PostSet).
For a simple example se the Test2.fmt file which will work together
with the Test2 table from the set of test tabels used by test.pl. To
view the content of the entire table, try:
Formated2.cgi?tab=Test2&fmt=Test2
Fld level fmt-format
-----------------------
The Fld level fmt strings are used to view a single Fld. They are
quite simple. To present a normal field your have only two special
variabels that can be used:
- Inserts the value of the field
- Inserts the name of the field
Relations will simply pass on there fmt string to the related posts
they represents. That means that an N2N relations wants a PostSet
level fmt string while a N2One relation wants a Post level fmt string
(se below).
All fld types can override the behaviour of the view_fmt and
default_fmt methods (se the DBIx::HTMLView::Fld manpage), which allows
them to specify the fmt formt used by them. Se there man pages for
detailed info.
Post level fmt-format
------------------------
The Post level fmt strings are used to view one single post. To insert
the values of the fld's of that post you use the "" or
"..." tags. The later allows you to specify the fmt
string used to view that Fld, which is very usefull when handling
relations. The first one simply inserts the fld using it's
default fmt, usualy it's value (se Named fmt's below).
PostSet level fmt-format
---------------------------
The PostSet level fmt strings are used to view several posts as
returned by the list method of DBIx::HTMLView::Table for exampel. It
should contain a "..." construct. The ... part will be
pased as a fmt to the Posts, then all the resulting post presentations
will be concated after eachother (currently it only supports one
"..." construct in the fmt string).
The starting tag can contain a join parameter (ie ""),
which will be placed between the posts presentations. For example:
will produce a comma separated list of posts, with the posts
represented by the field Name.
If no tags are specifed they are defaulting to include
the entire fmt string.
Named fmt's
-----------
In the Table definition it is possible to define named fmt strings
(currently only possibly at the Fld level, but should be possible at
all levels in the future). When you then eval an fmt string into an
presentatin string (with the view_fmt method) you always specify which
default fmt string should be used by .
To simplify your creation of fmt strings there is a few default named
fmt strings that will always be defined for all flds:
view_html - The PostSet, Post and Fld formated nicely using html tabels
edit_html - The Fld's presented with html tags to be
used in a html form for editing the Post using the
View.cgi script (curently not working on the PostSet
level).
view_text - The PostSet, Post and Fld in a plantext format.