[Koha-devel] feasibility of external circulation updating Koha items table availability
Galen Charlton
gmcharlt at gmail.com
Sun Feb 21 00:25:30 CET 2010
Hi,
On Fri, Feb 19, 2010 at 4:48 PM, Christopher Curry <ccurry at amphilsoc.org> wrote:
> Just to verify, I can call the itemnumber variable with:
>
> <!-- TMPL_VAR NAME="itemnumber" -->
>
> right?
Correct, although only in the TMPL_LOOP that goes through the item data.
> It seems like these variables usually use the MySQL field name, which is
> very logical. Is that a good rule of thumb to follow when determining if a
> variable is available to a template?
It's a reasonably good rule of thumb, but not a perfect one.
> Any idea where these variables are
> defined? I have fundamental programming knowledge, but don't know much
> about perl. Thanks for answering the novice questions.
Koha uses HTML::Template::Pro for its templating. Basically, an
HTML::Template::Pro object is created that binds itself to a
particular template, and variables are passed to the template via the
param() method. get_template_and_user() in C4::Auth is a wrapper
that, among other things, creates the template object, which is
normally referred to as $template in the Perl scripts.
In the simplest case, to pass a scalar value to the template, you
would do something like this:
$template->param(bar => 'value');
In the template, that value would be retrieved using
<!-- TMPL_VAR NAME="bar" -->
You can also pass more complicated data structures. For example:
$template->param(
myloop => [
{ value => 'abc' },
{ value => 'def' },
],
);
which can be retrieved via
<!-- TMPL_LOOP NAME="myloop" -->
<!-- TMPL_VAR NAME="value" -->
<!-- /TMPL_LOOP -->
which would emit
abc
def
Regards,
Galen
--
Galen Charlton
gmcharlt at gmail.com
More information about the Koha-devel
mailing list