Bugzilla – Attachment 86733 Details for
Bug 22318
Extend Koha news feature to include other content areas
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22318: Extend Koha news feature to include other content areas
Bug-22318-Extend-Koha-news-feature-to-include-othe.patch (text/plain), 4.22 KB, created by
Josef Moravec
on 2019-03-19 08:29:55 UTC
(
hide
)
Description:
Bug 22318: Extend Koha news feature to include other content areas
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2019-03-19 08:29:55 UTC
Size:
4.22 KB
patch
obsolete
>From bd416725b7c90859035cf3be6dc2593133fb1cf7 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Thu, 14 Feb 2019 15:46:24 +0000 >Subject: [PATCH] Bug 22318: Extend Koha news feature to include other content > areas > >This patch lays the groundwork for using the Koha news tool to replace >OPAC system preferences which embed HTML content in the Koha interface. >This will allow multiple translations of these content blocks to be >created. > >This adds a new template plugin, KohaNews. It has a single subroutine, >get(), which takes three parameters: > > - "location" -- the area of the template where the content will appear. > This will correspond to the system preference it replaces: > OpacMainUserBlock, OpacNavRight, etc. > - "lang" -- the user's currently-selected language. > - "library" -- the user's home library (if they are logged in) > >A new "koha_news_block" block is added to the OPAC templates' >html_helpers include. The content area is activated in the template >using this syntax: > >[% PROCESS koha_news_block news => KohaNews.get( location => >"OpacNavRight", lang => news_lang, library => branchcode ) %] > >Signed-off-by: Michal Denar <black23@gmail.com> > >Signed-off-by: Michal Denar <black23@gmail.com> > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > Koha/Template/Plugin/KohaNews.pm | 73 ++++++++++++++++++++++ > .../bootstrap/en/includes/html_helpers.inc | 13 ++++ > 2 files changed, 86 insertions(+) > create mode 100644 Koha/Template/Plugin/KohaNews.pm > >diff --git a/Koha/Template/Plugin/KohaNews.pm b/Koha/Template/Plugin/KohaNews.pm >new file mode 100644 >index 0000000000..49299f6e3d >--- /dev/null >+++ b/Koha/Template/Plugin/KohaNews.pm >@@ -0,0 +1,73 @@ >+package Koha::Template::Plugin::KohaNews; >+ >+# Copyright ByWater Solutions 2012 >+# Copyright BibLibre 2014 >+# Parts copyright Athens County Public Libraries 2019 >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Template::Plugin; >+use base qw( Template::Plugin ); >+ >+use C4::Koha; >+use C4::Context; >+use C4::NewsChannels; # GetNewsToDisplay >+ >+sub get { >+ my ( $self, $params ) = @_; >+ >+ my $display_location = $params->{location}; >+ my $lang = $params->{lang}; >+ my $library = $params->{library} || ""; >+ my $news_lang; >+ >+ if( !$display_location ){ >+ $news_lang = $lang; >+ } else { >+ $news_lang = $display_location."_".$lang; >+ } >+ >+ my $content = &GetNewsToDisplay( $news_lang, $library ); >+ >+ return $content; >+} >+ >+1; >+ >+=head1 NAME >+ >+Koha::Template::Plugin::KohaNews - TT Plugin for displaying Koha news >+ >+=head1 SYNOPSIS >+ >+[% USE KohaNews %] >+ >+[% KohaNews.get() %] >+ >+=head1 ROUTINES >+ >+=head2 get >+ >+In a template, you can get the all categories with >+the following TT code: [% KohaNews.get() %] >+ >+=head1 AUTHOR >+ >+Owen Leonard <oleonard@myacpl.org> >+ >+=cut >\ No newline at end of file >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/html_helpers.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/html_helpers.inc >index 2c7d34934b..8cb9d2f674 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/html_helpers.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/html_helpers.inc >@@ -7,3 +7,16 @@ > [% END%] > [% END %] > [% END %] >+ >+[% BLOCK koha_news_block %] >+ [% IF ( news.size > 0 ) %] >+ [% FOREACH n IN news %] >+ <div class="[% n.lang | html %]_item"> >+ [% IF ( n.title ) %] >+ <h4 class="[% n.lang | html %]_header">[% n.title | html %]</h4> >+ [% END %] >+ <div class="[% n.lang | html %]_body">[% n.content | $raw %]</div> >+ </div> >+ [% END %] >+ [% END %] >+[% END %] >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 22318
:
85132
|
85133
|
86728
|
86730
|
86731
|
86733
|
86734
|
86743
|
86771
|
87490
|
87491
|
87492
|
87493