[Koha-patches] [PATCH] Fix for Bug 6364 - Display of item availability broken on OPAC detail screen

Frédéric Demians f.demians at tamil.fr
Sat May 21 08:45:02 CEST 2011


From: Owen Leonard <oleonard at myacpl.org>

Owen:

The markup for showing item availability has been moved to an include
file. The include lacked the scope declaration for the item results
loop. Adding the scope declaration to the include file means it can't
be used by other template unless within the same scope, but I'm not
aware of a better way to do it given the number of variables in use.

Frédéric:

I confirm the bug.

I propose a alternative solution which solve the bug and keep its
versability-reusability to the include file. With this solution, when including
item-status.inc, the foreach loop variable name, which can change from template
to template, is renamed by using a local variable definition: ie a variable
name specified after file name in the INCLUDE directive, this variable
temporalily masking any existing variable.
---
 .../opac-tmpl/prog/en/includes/item-status.inc     |   36 ++++++++++----------
 koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt |    2 +-
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/item-status.inc b/koha-tmpl/opac-tmpl/prog/en/includes/item-status.inc
index fcfe120..d05583f 100644
--- a/koha-tmpl/opac-tmpl/prog/en/includes/item-status.inc
+++ b/koha-tmpl/opac-tmpl/prog/en/includes/item-status.inc
@@ -1,32 +1,32 @@
-[% IF ( datedue ) %]
+[% IF ( item.datedue ) %]
     [% IF ( OPACShowCheckoutName ) %]
-        Checked out to [% cardnumber %] [% firstname %] [% surname %]
+        Checked out to [% item.cardnumber %] [% item.firstname %] [% item.surname %]
     [% ELSE %]
         Checked out
     [% END %]
-[% ELSIF ( transfertwhen ) %]
-    In transit from [% transfertfrom %]
-    to [% transfertto %] since [% transfertwhen %]
-[% ELSIF ( waiting ) %]
+[% ELSIF ( item.transfertwhen ) %]
+    In transit from [% item.transfertfrom %]
+    to [% item.transfertto %] since [% item.transfertwhen %]
+[% ELSIF ( item.waiting ) %]
     On hold
-[% ELSIF ( wthdrawn ) %]
+[% ELSIF ( item.wthdrawn ) %]
     Item withdrawn
-[% ELSIF ( itemlost ) %]
-    [% IF ( lostimageurl ) %]
-        <img src="[% lostimageurl %]" alt="[% lostimagelabel %]" title="[% lostimagelabel %]">
+[% ELSIF ( item.itemlost ) %]
+    [% IF ( item.lostimageurl ) %]
+        <img src="[% item.lostimageurl %]" alt="[% item.lostimagelabel %]" title="[% item.lostimagelabel %]">
     [% ELSE %]
         Item lost
     [% END %]
-[% ELSIF ( itemnotforloan ) %]
-    [% IF ( notforloanvalue ) %]
-        [% notforloanvalue %] [% IF ( restrictedopac ) %]<span class="restricted">([% restrictedopac %])</span>[% END %]
+[% ELSIF ( item.itemnotforloan ) %]
+    [% IF ( item.notforloanvalue ) %]
+        [% item.notforloanvalue %] [% IF ( item.restrictedopac ) %]<span class="restricted">([% item.restrictedopac %])</span>[% END %]
     [% ELSE %]
-        Not for loan [% IF ( restrictedopac ) %]<span class="restricted">([% restrictedopac %])</span>[% END %]
+        Not for loan [% IF ( item.restrictedopac ) %]<span class="restricted">([% item.restrictedopac %])</span>[% END %]
     [% END %]
-[% ELSIF ( notforloan_per_itemtype ) %]
-    Not for loan [% IF ( restrictedopac ) %]<span class="restricted">([% restrictedopac %])</span>[% END %]
-[% ELSIF ( damaged ) %]
+[% ELSIF ( item.notforloan_per_itemtype ) %]
+    Not for loan [% IF ( item.restrictedopac ) %]<span class="restricted">([% item.restrictedopac %])</span>[% END %]
+[% ELSIF ( item.damaged ) %]
     Item damaged
 [% ELSE %]
-    Available [% IF ( restrictedopac ) %]<span class="restricted">([% restrictedopac %])</span>[% END %]
+    Available [% IF ( item.restrictedopac ) %]<span class="restricted">([% item.restrictedopac %])</span>[% END %]
 [% END %]
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt
index 7263b1e..ff4b52c 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt
@@ -410,7 +410,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
 		[% IF ( itemdata_enumchron ) %]<td>[% ITEM_RESULT.enumchron %]</td>[% END %]
 		[% IF ( itemdata_uri ) %]<td><a href="[% ITEM_RESULT.uri %]">[% ITEM_RESULT.uri %]</a></td>[% END %]
 		[% IF ( itemdata_copynumber ) %]<td>[% ITEM_RESULT.copynumber %]</td>[% END %]
-		<td>[% INCLUDE 'item-status.inc' %]</td>
+		<td>[% INCLUDE 'item-status.inc' item = ITEM_RESULT %]</td>
 		[% IF ( itemdata_itemnotes ) %]<td>[% ITEM_RESULT.itemnotes %]</td>[% END %]
 		<td>[% ITEM_RESULT.datedue %]</td>
 		[% IF ( ITEM_RESULT.type ) %]
-- 
1.7.5.1



More information about the Koha-patches mailing list