[Koha-patches] [PATCH] Bug 5830 Using XSLT on OPAC Lists page

Frédéric Demians f.demians at tamil.fr
Fri Mar 4 20:05:24 CET 2011


On OPAC Lists page (opac-shelves.pl), biblio records are now displayed
accordingly to OPACXSLTResultsDisplay system preference.
---
 C4/VirtualShelves/Page.pm                          |    9 ++-
 .../opac-tmpl/prog/en/includes/biblioresult.inc    |   61 +++++++++++++++++++
 .../opac-tmpl/prog/en/modules/opac-results.tmpl    |   64 +-------------------
 .../opac-tmpl/prog/en/modules/opac-shelves.tmpl    |   24 +-------
 4 files changed, 71 insertions(+), 87 deletions(-)
 create mode 100644 koha-tmpl/opac-tmpl/prog/en/includes/biblioresult.inc

diff --git a/C4/VirtualShelves/Page.pm b/C4/VirtualShelves/Page.pm
index 66c614d..4d9ccb6 100644
--- a/C4/VirtualShelves/Page.pm
+++ b/C4/VirtualShelves/Page.pm
@@ -35,6 +35,7 @@ use C4::Tags qw(get_tags);
 use Exporter;
 use Data::Dumper;
 use C4::Csv;
+use C4::XSLT;
 
 use vars qw($debug @EXPORT @ISA $VERSION);
 
@@ -201,7 +202,11 @@ sub shelfpage ($$$$$) {
                 }
                 ( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset );
                 for my $this_item (@$items) {
-                    my $record = GetMarcBiblio( $this_item->{'biblionumber'} );
+                    my $biblionumber = $this_item->{'biblionumber'};
+                    my $record = GetMarcBiblio($biblionumber);
+                    $this_item->{XSLTResultsRecord} =
+                        XSLTParse4Display($biblionumber, $record, 'Results', 'opac')
+                            if C4::Context->preference("OPACXSLTResultsDisplay");
 
                     # the virtualshelfcontents table does not store these columns nor are they retrieved from the items
                     # and itemtypes tables, so I'm commenting them out for now to quiet the log -crn
@@ -218,7 +223,7 @@ sub shelfpage ($$$$$) {
                     # Getting items infos for location display
                     my @items_infos = &GetItemsInfo( $this_item->{'biblionumber'}, $type );
                     $this_item->{'itemsissued'} = CountItemsIssued( $this_item->{'biblionumber'} );
-                    $this_item->{'ITEM_RESULTS'} = \@items_infos;
+                    $this_item->{available_items_loop} = \@items_infos;
 
                     if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->preference('TagsShowOnList')) {
                         $this_item->{'TagLoop'} = get_tags({
diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/biblioresult.inc b/koha-tmpl/opac-tmpl/prog/en/includes/biblioresult.inc
new file mode 100644
index 0000000..ab404f5
--- /dev/null
+++ b/koha-tmpl/opac-tmpl/prog/en/includes/biblioresult.inc
@@ -0,0 +1,61 @@
+<!-- TMPL_IF NAME="OPACXSLTResultsDisplay" -->
+<!-- TMPL_VAR NAME="XSLTResultsRecord" -->
+<!-- TMPL_ELSE -->
+<!-- TMPL_IF name="BiblioDefaultViewmarc" --><a class="title" href="/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->" title="View details for this title">
+<!-- TMPL_ELSE -->
+<!-- TMPL_IF name="BiblioDefaultViewisbd" --><a class="title" href="/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->" title="View details for this title">
+<!-- TMPL_ELSE --><a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->" title="View details for this title">
+<!-- /TMPL_IF -->
+<!-- /TMPL_IF -->
+								<!-- TMPL_IF NAME="title" --><!-- TMPL_VAR NAME="title" ESCAPE="html" --><!-- TMPL_ELSE -->No title<!-- /TMPL_IF --> <!-- TMPL_LOOP NAME="subtitle"  --><!--TMPL_VAR Name="subfield"--><!--/TMPL_LOOP--></a>
+<!-- TMPL_IF NAME="author" -->by <a href="/cgi-bin/koha/opac-search.pl?q=au:<!-- TMPL_VAR NAME="author" ESCAPE="URL" -->" title="Search for works by this author" class="author"><!-- TMPL_VAR NAME="author" --></a>
+<!-- TMPL_ELSE -->&nbsp;
+<!-- /TMPL_IF -->
+				<span class="results_summary"><span class="label">Publication:</span>
+<!-- TMPL_IF name="place" --><!-- TMPL_VAR name="place" --> <!-- /TMPL_IF --><!-- TMPL_IF name="publishercode" --><!-- TMPL_VAR name="publishercode" --><!-- /TMPL_IF --><!-- TMPL_IF name="publicationyear" --> <!-- TMPL_VAR name="publicationyear" -->
+<!-- TMPL_ELSE --><!-- TMPL_IF name="copyrightdate" --> <!-- TMPL_VAR name="copyrightdate" --><!-- /TMPL_IF --><!-- /TMPL_IF -->
+<!-- TMPL_IF name="pages" -->. <!-- TMPL_VAR name="pages" --><!-- /TMPL_IF -->
+<!-- TMPL_IF name="notes" -->, <!-- TMPL_VAR name="notes" --><!-- /TMPL_IF -->
+<!-- TMPL_IF name="size" --> <!-- TMPL_VAR name="size" --><!-- /TMPL_IF -->
+<!-- TMPL_IF name="timestamp" --> <i>(modified on <!-- TMPL_VAR name="timestamp" -->)</i><!-- /TMPL_IF -->
+</span>
+<!-- TMPL_IF NAME="summary" -->
+<span class="result_summary">
+	<!-- TMPL_VAR name="summary" -->
+</span>
+<!-- /TMPL_IF -->
+<!-- TMPL_IF NAME="copyrightdate" --><span class="results_summary"><span class="label">Date:</span><!-- TMPL_VAR NAME="copyrightdate" --></span><!-- /TMPL_IF -->
+
+<span class="results_summary">
+<span class="label">Availability:</span>
+<!-- TMPL_IF NAME="available_items_loop" -->
+<span class="available"><strong>Copies available:</strong>
+<!-- TMPL_LOOP NAME="available_items_loop" -->
+
+<!-- TMPL_IF NAME="singleBranchMode" -->
+<!-- TMPL_VAR NAME="location" -->
+<!-- TMPL_ELSE -->
+<!-- TMPL_VAR NAME="branchname" -->
+<!-- /TMPL_IF -->
+
+<!-- TMPL_IF name="OPACItemsResultsDisplay" -->
+					    <!-- TMPL_UNLESS NAME="singleBranchMode" --><!-- TMPL_VAR NAME="location" --><!-- /TMPL_UNLESS -->
+<!-- TMPL_IF NAME="itemcallnumber" -->[<a href="/cgi-bin/koha/opac-search.pl?q=callnum:<!-- TMPL_VAR NAME="itemcallnumber" ESCAPE="URL" -->"><!-- TMPL_VAR NAME="itemcallnumber" --></a>]<!-- /TMPL_IF -->
+<!-- /TMPL_IF -->
+(<!-- TMPL_VAR NAME="count" -->),
+<!-- /TMPL_LOOP -->
+</span>
+<!-- TMPL_ELSE -->
+<span class="unavailable">No items available:</span>
+<!-- /TMPL_IF -->
+<span class="unavailable">
+<!-- TMPL_IF NAME="onloancount" --> Checked out (<!-- TMPL_VAR NAME="onloancount" -->), <!-- /TMPL_IF -->
+<!-- TMPL_IF NAME="wthdrawncount" --> Withdrawn (<!-- TMPL_VAR NAME="wthdrawncount" -->), <!-- /TMPL_IF -->
+<!-- TMPL_UNLESS NAME="hidelostitems" --><!-- TMPL_IF NAME="itemlostcount" --> Lost (<!-- TMPL_VAR NAME="itemlostcount" -->),<!-- /TMPL_IF --><!-- /TMPL_UNLESS -->
+<!-- TMPL_IF NAME="damagedcount" --> Damaged (<!-- TMPL_VAR NAME="damagedcount" -->),<!-- /TMPL_IF -->
+<!-- TMPL_IF NAME="orderedcount" --> On order (<!-- TMPL_VAR NAME="orderedcount" -->),<!-- /TMPL_IF -->
+<!-- TMPL_IF NAME="onholdcount" --> On hold (<!-- TMPL_VAR NAME="onholdcount" -->),<!-- /TMPL_IF -->
+<!-- TMPL_IF NAME="intransitcount" --> In transit (<!-- TMPL_VAR NAME="intransitcount" -->),<!-- /TMPL_IF -->
+</span>
+</span>
+<!-- /TMPL_IF -->
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl
index d7aff2e..9a646ad 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl
@@ -398,68 +398,8 @@ $(document).ready(function(){
                     <!-- COinS / OpenURL --><span class="Z3988" title="<!-- TMPL_VAR NAME="coins" -->"></span>
                 <!-- /TMPL_IF -->
 
-				<!-- TMPL_IF NAME="OPACXSLTResultsDisplay" -->
-                <!-- TMPL_VAR NAME="XSLTResultsRecord" -->
-				<!-- TMPL_ELSE -->
-				<!-- TMPL_IF name="BiblioDefaultViewmarc" --><a class="title" href="/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->" title="View details for this title">
-                                <!-- TMPL_ELSE -->
-                                <!-- TMPL_IF name="BiblioDefaultViewisbd" --><a class="title" href="/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->" title="View details for this title">
-                                <!-- TMPL_ELSE --><a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->" title="View details for this title">
-                                <!-- /TMPL_IF -->
-                                <!-- /TMPL_IF -->
-								<!-- TMPL_IF NAME="title" --><!-- TMPL_VAR NAME="title" ESCAPE="html" --><!-- TMPL_ELSE -->No title<!-- /TMPL_IF --> <!-- TMPL_LOOP NAME="subtitle"  --><!--TMPL_VAR Name="subfield"--><!--/TMPL_LOOP--></a>
-                                <!-- TMPL_IF NAME="author" -->by <a href="/cgi-bin/koha/opac-search.pl?q=au:<!-- TMPL_VAR NAME="author" ESCAPE="URL" -->" title="Search for works by this author" class="author"><!-- TMPL_VAR NAME="author" --></a>
-                                <!-- TMPL_ELSE -->&nbsp;
-                                <!-- /TMPL_IF -->
-				<span class="results_summary"><span class="label">Publication:</span>
-                        <!-- TMPL_IF name="place" --><!-- TMPL_VAR name="place" --> <!-- /TMPL_IF --><!-- TMPL_IF name="publishercode" --><!-- TMPL_VAR name="publishercode" --><!-- /TMPL_IF --><!-- TMPL_IF name="publicationyear" --> <!-- TMPL_VAR name="publicationyear" -->
-                    <!-- TMPL_ELSE --><!-- TMPL_IF name="copyrightdate" --> <!-- TMPL_VAR name="copyrightdate" --><!-- /TMPL_IF --><!-- /TMPL_IF -->
-                        <!-- TMPL_IF name="pages" -->. <!-- TMPL_VAR name="pages" --><!-- /TMPL_IF -->
-                        <!-- TMPL_IF name="notes" -->, <!-- TMPL_VAR name="notes" --><!-- /TMPL_IF -->
-                        <!-- TMPL_IF name="size" --> <!-- TMPL_VAR name="size" --><!-- /TMPL_IF -->
-                        <!-- TMPL_IF name="timestamp" --> <i>(modified on <!-- TMPL_VAR name="timestamp" -->)</i><!-- /TMPL_IF -->
-                </span>
-                <!-- TMPL_IF NAME="summary" -->
-                <span class="result_summary">
-                	<!-- TMPL_VAR name="summary" -->
-                </span>
-                <!-- /TMPL_IF -->
-                <!-- TMPL_IF NAME="copyrightdate" --><span class="results_summary"><span class="label">Date:</span><!-- TMPL_VAR NAME="copyrightdate" --></span><!-- /TMPL_IF -->
-
-				<span class="results_summary">
-                <span class="label">Availability:</span>
-                    <!-- TMPL_IF NAME="available_items_loop" -->
-                    <span class="available"><strong>Copies available:</strong>
-                    <!-- TMPL_LOOP NAME="available_items_loop" -->
-
-                    <!-- TMPL_IF NAME="singleBranchMode" -->
-                        <!-- TMPL_VAR NAME="location" -->
-                    <!-- TMPL_ELSE -->
-                        <!-- TMPL_VAR NAME="branchname" -->
-                    <!-- /TMPL_IF -->
-
-                    <!-- TMPL_IF name="OPACItemsResultsDisplay" -->
-					    <!-- TMPL_UNLESS NAME="singleBranchMode" --><!-- TMPL_VAR NAME="location" --><!-- /TMPL_UNLESS -->
-                        <!-- TMPL_IF NAME="itemcallnumber" -->[<a href="/cgi-bin/koha/opac-search.pl?q=callnum:<!-- TMPL_VAR NAME="itemcallnumber" ESCAPE="URL" -->"><!-- TMPL_VAR NAME="itemcallnumber" --></a>]<!-- /TMPL_IF -->
-                    <!-- /TMPL_IF -->
-                    (<!-- TMPL_VAR NAME="count" -->),
-                    <!-- /TMPL_LOOP -->
-                    </span>
-                    <!-- TMPL_ELSE -->
-                    <span class="unavailable">No items available:</span>
-                    <!-- /TMPL_IF -->
-                    <span class="unavailable">
-                    <!-- TMPL_IF NAME="onloancount" --> Checked out (<!-- TMPL_VAR NAME="onloancount" -->), <!-- /TMPL_IF -->
-                    <!-- TMPL_IF NAME="wthdrawncount" --> Withdrawn (<!-- TMPL_VAR NAME="wthdrawncount" -->), <!-- /TMPL_IF -->
-                    <!-- TMPL_UNLESS NAME="hidelostitems" --><!-- TMPL_IF NAME="itemlostcount" --> Lost (<!-- TMPL_VAR NAME="itemlostcount" -->),<!-- /TMPL_IF --><!-- /TMPL_UNLESS -->
-                    <!-- TMPL_IF NAME="damagedcount" --> Damaged (<!-- TMPL_VAR NAME="damagedcount" -->),<!-- /TMPL_IF -->
-                    <!-- TMPL_IF NAME="orderedcount" --> On order (<!-- TMPL_VAR NAME="orderedcount" -->),<!-- /TMPL_IF -->
-                    <!-- TMPL_IF NAME="onholdcount" --> On hold (<!-- TMPL_VAR NAME="onholdcount" -->),<!-- /TMPL_IF -->
-                    <!-- TMPL_IF NAME="intransitcount" --> In transit (<!-- TMPL_VAR NAME="intransitcount" -->),<!-- /TMPL_IF -->
-                    </span>
-                </span>
+<!-- TMPL_INCLUDE NAME="biblioresult.inc" -->
 
-				<!-- /TMPL_IF -->
 				<!-- TMPL_IF NAME="LibraryThingForLibrariesID" --><div class="ltfl_reviews"></div><!-- /TMPL_IF -->
 				<!-- TMPL_IF NAME="opacuserlogin" --><!-- TMPL_IF NAME="TagsEnabled" -->
                                 <!-- TMPL_IF NAME="TagsShowOnList" -->
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tmpl
index 1e1d2d5..b882cd7 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tmpl
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tmpl
@@ -249,29 +249,7 @@ $(function() {
                         </td>
                     <!-- /TMPL_UNLESS -->
                         <td>
-                                <!-- TMPL_IF name="BiblioDefaultViewmarc" --><a class="title" href="/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->" title="View details for this title">
-                                <!-- TMPL_ELSE -->
-                                <!-- TMPL_IF name="BiblioDefaultViewisbd" --><a class="title" href="/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->" title="View details for this title">
-                                <!-- TMPL_ELSE --><a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->" title="View details for this title">
-                                <!-- /TMPL_IF -->
-                                <!-- /TMPL_IF -->
-                <!-- TMPL_IF NAME="title" --><!-- TMPL_VAR NAME="title" ESCAPE="html" --><!-- TMPL_ELSE -->No title<!-- /TMPL_IF --> <!-- TMPL_LOOP NAME="subtitle"  --><!--TMPL_VAR Name="subfield"--><!--/TMPL_LOOP--></a>
-                                <!-- TMPL_IF NAME="author" -->by <a href="/cgi-bin/koha/opac-search.pl?q=au:<!-- TMPL_VAR NAME="author" ESCAPE="URL" -->" title="Search for works by this author" class="author"><!-- TMPL_VAR NAME="author" --></a>
-                                <!-- TMPL_ELSE -->&nbsp;
-                                <!-- /TMPL_IF -->
-        <span class="results_summary"><span class="label">Publication:</span>
-                        <!-- TMPL_IF name="place" --><!-- TMPL_VAR name="place" --> <!-- /TMPL_IF --><!-- TMPL_IF name="publishercode" --><!-- TMPL_VAR name="publishercode" --><!-- /TMPL_IF --><!-- TMPL_IF name="publicationyear" --> <!-- TMPL_VAR name="publicationyear" -->
-                    <!-- TMPL_ELSE --><!-- TMPL_IF name="copyrightdate" --> <!-- TMPL_VAR name="copyrightdate" --><!-- /TMPL_IF --><!-- /TMPL_IF -->
-                        <!-- TMPL_IF name="pages" -->. <!-- TMPL_VAR name="pages" --><!-- /TMPL_IF -->
-                        <!-- TMPL_IF name="notes" -->, <!-- TMPL_VAR name="notes" --><!-- /TMPL_IF -->
-                        <!-- TMPL_IF name="size" --> <!-- TMPL_VAR name="size" --><!-- /TMPL_IF -->
-                </span>
-                <span class="results_summary"><span class="label">Holdings:</span><!-- TMPL_IF NAME="ITEM_RESULTS" --><!-- TMPL_LOOP NAME="ITEM_RESULTS" -->
-          <!-- TMPL_VAR NAME="branchname" --><!-- TMPL_IF NAME="location" -->, <!-- TMPL_VAR NAME="location" --><!-- /TMPL_IF -->
-          <!-- TMPL_IF name="itemcallnumber" -->
-        (<!-- TMPL_VAR NAME="itemcallnumber" -->)<!-- TMPL_IF NAME="__LAST__" -->.<!-- TMPL_ELSE -->,<!-- /TMPL_IF -->
-          <!-- /TMPL_IF -->
-          <!-- /TMPL_LOOP --><!-- TMPL_ELSE -->This record has no items.<!-- /TMPL_IF --></span>
+<!-- TMPL_INCLUDE NAME="biblioresult.inc" -->
 
         <!-- TMPL_IF NAME="TagsEnabled" -->
                 <!-- TMPL_IF NAME="TagsShowOnList" -->
-- 
1.7.4



More information about the Koha-patches mailing list