CGI-WebToolkit

 view release on metacpan or  search on metacpan

lib/CGI/WebToolkit.pm  view on Meta::CPAN


B<{script_url}>

The URL of the script executable, including the script name.

B<{public_url}>

The URL of the public directory.

B<{clear}>

The special XHTML snippet <div class="clear"></div>

B<{do_nothing_url}>

This URL can be used in Links that should do nothing.
It containts the Javascript snippet javascript:void(1);

B<{javascript_url}>

This URL points to the special core workflow function I<core.combine.javascript>
and therefor points to a combined javascript.

B<{css_url}>

This URL points to the special core workflow function I<core.combine.css>
and therefor points to a combined stylesheet.


=head3 Default placeholder values

Any placeholders in a template that have not been filled, are
by default replaced with an empty string. Sometimes you want to
have a special default value instead of the empty string.
Example:

	<b>{title:This is the default title}</b>


=head3 Simplified calling of fill()

To make it visually clearer what template is filled, there is an
alternative way of calling the fill() method. The following
statements mean the same:

	my $string = $wtk->fill('form.date', {-month => '...', -year => '...'});
	
	my $string = $wtk->FormDate(-month => '...', -year => '...');

Using the general method of using the functional style of
invocation, this even gets shorter:

	my $string = FormDate(-month => '...', -year => '...');

In case you want the template from a specific theme, use this
syntax for the functional invocation:

	my $string = Core_FormDate(-month => '...', -year => '...');


=head3 Template Macros

Template macros are a way of loading templates from within
templates.

For example, if you want to create a general piece of markup
that is considered "a box", you wish you were able to
keep this markup in one place and use it from anywhere else
in other templates. That is what these macros are for.

Example of a box markup:

     <div class="box">
     	<h1>{title}</h1>
     	<p>{content}</p>
     </div>

This markup goes in a file called I<templates/my_project/box.html>
(in our example).

And here is how to use the box markup inside another template:

	<h1>Hallo!</h2>
	<box title="My Box">In the box.</box>

The macro processor allows recursive notation of macros,
so that the following works as expected:

	<box>In the <box>other box</box> box.</box>






=head2 Methods for database access

To access the data that is stored inside the attached (relational) database, CGI::WebToolkit
offers some handy functions.
When the CGI::WebToolkit instance is created, all information regarding the database
connection is given and CGI::WebToolkit will try to establish a connection.

Internally, a DBI instance is created, so any kind of database can be
used for which a DBI driver is provided.

Any fieldname noted below can consist of the field's name only or addiontally
the tablename, e.g. I<myfield> and I<mytable.myfield> are both valid
field names.

=head3 find()

To retrieve records from the database, use the select() method:

	my $query = $wtk->find(
	  -tables 	=> [qw(mytable1 mytable2 ...)],
	  -where 		=> { name => "...", ... },
	  -wherelike 	=> {...},
	  -group 		=> [qw(id name ...)],
	  -order 		=> [qw(id name ...)],
	  -limit 		=> 10,
	  -distinct 	=> 1,



( run in 0.887 second using v1.01-cache-2.11-cpan-39bf76dae61 )