[Koha-devel] Template Toolkit BLOCK in INCLUDE file

David Cook dcook at prosentient.com.au
Wed Jan 28 04:30:02 CET 2015


Hi all:

 

I was looking at defining some TT BLOCKs in an include file which I would
INCLUDE into my main template and then PROCESS as needed (as part of bug
13631 http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=13631).

 

However, I noticed that you can't access a BLOCK in an included file. I
noticed some seemingly non-functional examples already in the Koha codebase.
For instance, in
"koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth-detail.tt" we try to
process the blocks from the include
"/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-authorities.inc", but from
what I can see. none of them work (you can try for yourself at
"/cgi-bin/koha/opac-authoritiesdetail.pl") . I also did heaps of tests
myself. If you PROCESS or INCLUDE another file, you get everything EXCEPT
the BLOCK.

 

It does seem like there are some ways around this though.

 

1)      If you use the EXPOSE_BLOCKS option in the Template->new()
constructor, you can directly INCLUDE/PROCESS a BLOCK from an included file.
(http://mail.template-toolkit.org/pipermail/templates/2002-July/003460.html)
. 

 

However, this option isn't documented in the official website at all, so I'd
be hesitant to use this.

 

2)      When you INCLUDE/PROCESS an external file, you can pass variables to
it. You could pass a variable to the external file, and have it execute
PROCESS/INCLUDE from within that file. 

 

At the moment, I'm doing the second.

 

David Cook

Systems Librarian

Prosentient Systems

72/330 Wattle St, Ultimo, NSW 2007

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20150128/ec5884c7/attachment.html>


More information about the Koha-devel mailing list