[Koha-devel] Template Toolkit BLOCK in INCLUDE file

Jonathan Druart jonathan.druart at biblibre.com
Wed Jan 28 12:24:49 CET 2015


Hello David,
Could you please give (even) more detail?
I think I don't understand what you are saying, I tested with a simple
example and it seems to work:

diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-authorities.inc
b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-authorities.inc
index aed68e5..d94ab92 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-authorities.inc
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-authorities.inc
@@ -1,3 +1,7 @@
+[% BLOCK test %]
+==== This is a test! [% s %]====
+[% END %]
+
 [% BLOCK showhierarchy %]
     [% FOREACH tree IN trees %]
         [% PROCESS showtree tree = tree %]
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth-detail.tt
b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth-detail.tt
index 703cea3..41c61e2 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth-detail.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth-detail.tt
@@ -58,6 +58,7 @@
                             [% PROCESS otherscript
headings=summary.otherscript wantcategory='preferred' %]
                         </div>

+[% PROCESS test s="Does it work?"%]
                         [% IF summary.seefrom.size %]
                             <div class="authstanza seefrom">
                                 <div class="authstanzaheading">Used
for/see from:</div>



I see
==== This is a test! Does it work?====

2015-01-28 4:30 GMT+01:00 David Cook <dcook at prosentient.com.au>:
> 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
>
>
>
>
> _______________________________________________
> Koha-devel mailing list
> Koha-devel at lists.koha-community.org
> http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
> website : http://www.koha-community.org/
> git : http://git.koha-community.org/
> bugs : http://bugs.koha-community.org/


More information about the Koha-devel mailing list