Main Koha release repository https://koha-community.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

83 lines
1.9 KiB

  1. package Koha::Template::Plugin::KohaNews;
  2. # Copyright ByWater Solutions 2012
  3. # Copyright BibLibre 2014
  4. # Parts copyright Athens County Public Libraries 2019
  5. # This file is part of Koha.
  6. #
  7. # Koha is free software; you can redistribute it and/or modify it
  8. # under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # Koha is distributed in the hope that it will be useful, but
  13. # WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with Koha; if not, see <http://www.gnu.org/licenses>.
  19. use Modern::Perl;
  20. use Template::Plugin;
  21. use base qw( Template::Plugin );
  22. use C4::Koha;
  23. use C4::Context;
  24. use C4::NewsChannels; # GetNewsToDisplay
  25. sub get {
  26. my ( $self, $params ) = @_;
  27. my $display_location = $params->{location};
  28. my $blocktitle = $params->{blocktitle};
  29. my $lang = $params->{lang};
  30. my $library = $params->{library} || "";
  31. my $news_lang;
  32. if( !$display_location ){
  33. $news_lang = $lang;
  34. } else {
  35. $news_lang = $display_location."_".$lang;
  36. }
  37. my $content = &GetNewsToDisplay( $news_lang, $library );
  38. if( @$content ){
  39. return {
  40. content => $content,
  41. location => $display_location,
  42. blocktitle => $blocktitle
  43. };
  44. } else {
  45. return;
  46. }
  47. }
  48. 1;
  49. =head1 NAME
  50. Koha::Template::Plugin::KohaNews - TT Plugin for displaying Koha news
  51. =head1 SYNOPSIS
  52. [% USE KohaNews %]
  53. [% KohaNews.get() %]
  54. =head1 ROUTINES
  55. =head2 get
  56. In a template, you can get the all categories with
  57. the following TT code: [% KohaNews.get() %]
  58. =head1 AUTHOR
  59. Owen Leonard <oleonard@myacpl.org>
  60. =cut