View | Details | Raw Unified | Return to bug 29691
Collapse All | Expand All

(-)a/Koha/Template/Plugin/AdditionalContents.pm (+23 lines)
Lines 55-60 sub get { Link Here
55
    }
55
    }
56
}
56
}
57
57
58
sub get_news_id {
59
    my ( $self, $params ) = @_;
60
61
    my $idnew   = $params->{idnew};
62
    my $location   = ['opac_only', 'staff_and_opac'];
63
    my $blocktitle = $params->{blocktitle};
64
65
    my $content = Koha::AdditionalContents->search(
66
        {
67
            location   => $location,
68
            idnew => $idnew,
69
        }
70
    );
71
72
    if ( $content->count ) {
73
        return {
74
            content    => $content,
75
            location   => $location,
76
            blocktitle => $blocktitle
77
        };
78
    }
79
}
80
58
1;
81
1;
59
82
60
=head1 NAME
83
=head1 NAME
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt (-55 / +52 lines)
Lines 71-77 Link Here
71
        <h1 class="sr-only">Koha home</h1>
71
        <h1 class="sr-only">Koha home</h1>
72
72
73
        [% IF Koha.Preference( 'OpacNewsLibrarySelect' ) %]
73
        [% IF Koha.Preference( 'OpacNewsLibrarySelect' ) %]
74
            [% UNLESS news_item %]
74
            [% UNLESS news_id %]
75
                <form id="news-branch-select" class="form-inline" name="news-branch-select" method="get" action="/cgi-bin/koha/opac-main.pl">
75
                <form id="news-branch-select" class="form-inline" name="news-branch-select" method="get" action="/cgi-bin/koha/opac-main.pl">
76
                    <legend class="sr-only">News</legend>
76
                    <legend class="sr-only">News</legend>
77
                    <label for="news-branch">Display news for: </label>
77
                    <label for="news-branch">Display news for: </label>
Lines 87-151 Link Here
87
            [% END %]
87
            [% END %]
88
        [% END %]
88
        [% END %]
89
89
90
        [% IF koha_news.count %]
90
        [% IF news_id %]
91
91
            [% SET koha_news = AdditionalContents.get_news_id( idnew => news_id ) %]
92
            [% IF single_news_error %]
92
        [% ELSE %]
93
93
            [% SET koha_news = AdditionalContents.get( category => 'news', location => ['opac_only', 'staff_and_opac'], lang => lang, library => branchcode ) %]
94
                <div class="alert alert-error">
94
        [% END %]
95
                    This news item does not exist.
95
        [% IF koha_news.content.count %]
96
                </div>
96
            <div id="news" class="newscontainer">
97
97
                [% SET show_author = Koha.Preference('NewsAuthorDisplay') == 'opac' || Koha.Preference('NewsAuthorDisplay') == 'both' %]
98
            [% ELSE %]
98
                [% FOREACH koha_new IN koha_news.content %]
99
                    <div class="newsitem">
100
                        <h4 class="newsheader">
101
                            [% IF ( news_item ) %]
102
                                [% koha_new.title | html %]
103
                            [% ELSE %]
104
                                <a name="newsitem[% koha_new.idnew | html %]" href="/cgi-bin/koha/opac-main.pl?news_id=[% koha_new.idnew | uri %]">[% koha_new.title | html %]</a>
105
                            [% END %]
106
                        </h4>
107
                        <div class="newsbody">[% koha_new.content | $raw %]</div>
108
                        <div class="newsfooter">
109
                            Published on [% koha_new.published_on | $KohaDates %]
110
                            [% IF ( show_author && koha_new.author ) %]
111
                                by <span class="newsauthor">[% INCLUDE 'patron-title.inc' patron=koha_new.author %]</span>
112
                            [% END %]
113
                            [% IF ( news_item ) %]
114
                                &bull; <a href="/cgi-bin/koha/opac-main.pl">Show all news</a>
115
                            [% END %]
116
                        </div>
117
                    </div>
118
                [% END %]
99
119
100
                <div id="news" class="newscontainer">
120
                [% UNLESS news_item %]
101
                    [% SET show_author = Koha.Preference('NewsAuthorDisplay') == 'opac' || Koha.Preference('NewsAuthorDisplay') == 'both' %]
121
                    <div id="rssnews-container">
102
                    [% FOREACH koha_new IN koha_news %]
122
                        <!-- Logged in users have a branch code or it could be explicitly set -->
103
                        <div class="newsitem">
123
                        <a href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-news-rss.pl?branchcode=[% branchcode | uri %]">
104
                            <h4 class="newsheader">
124
                            <i class="fa fa-rss" aria-hidden="true"></i>
105
                                [% IF ( news_item ) %]
125
                            [% IF Branches.all.size == 1 %]
106
                                    [% koha_new.title | html %]
126
                                [% IF branchcode %]
127
                                    RSS feed for [% Branches.GetName( branchcode ) | html %] library news
107
                                [% ELSE %]
128
                                [% ELSE %]
108
                                    <a name="newsitem[% koha_new.idnew | html %]" href="/cgi-bin/koha/opac-main.pl?news_id=[% koha_new.idnew | uri %]">[% koha_new.title | html %]</a>
129
                                    RSS feed for library news
109
                                [% END %]
110
                            </h4>
111
                            <div class="newsbody">[% koha_new.content | $raw %]</div>
112
                            <div class="newsfooter">
113
                                Published on [% koha_new.published_on | $KohaDates %]
114
                                [% IF ( show_author && koha_new.author ) %]
115
                                    by <span class="newsauthor">[% INCLUDE 'patron-title.inc' patron=koha_new.author %]</span>
116
                                [% END %]
117
                                [% IF ( news_item ) %]
118
                                    &bull; <a href="/cgi-bin/koha/opac-main.pl">Show all news</a>
119
                                [% END %]
130
                                [% END %]
120
                            </div>
131
                            [% ELSE %]
121
                        </div>
132
                                [% IF branchcode %]
122
                    [% END %]
133
                                    RSS feed for [% Branches.GetName( branchcode ) | html %] and system-wide library news
123
124
                    [% UNLESS news_item %]
125
                        <div id="rssnews-container">
126
                            <!-- Logged in users have a branch code or it could be explicitly set -->
127
                            <a href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-news-rss.pl?branchcode=[% branchcode | uri %]">
128
                                <i class="fa fa-rss" aria-hidden="true"></i>
129
                                [% IF Branches.all.size == 1 %]
130
                                    [% IF branchcode %]
131
                                        RSS feed for [% Branches.GetName( branchcode ) | html %] library news
132
                                    [% ELSE %]
133
                                        RSS feed for library news
134
                                    [% END %]
135
                                [% ELSE %]
134
                                [% ELSE %]
136
                                    [% IF branchcode %]
135
                                    RSS feed for system-wide library news
137
                                        RSS feed for [% Branches.GetName( branchcode ) | html %] and system-wide library news
138
                                    [% ELSE %]
139
                                        RSS feed for system-wide library news
140
                                    [% END %]
141
                                [% END %]
136
                                [% END %]
142
                            </a>
137
                            [% END %]
143
                        </div>
138
                        </a>
144
                    [% END %]
139
                    </div>
145
                </div>
140
                [% END %]
146
141
            </div>
147
            [% END # /IF single_news_error %]
142
        [% ELSIF news_id %] <!-- news_id but no koha_news.content -->
148
143
            <div class="alert alert-error">
144
                This news item does not exist.
145
            </div>
149
        [% ELSE %] <!-- koha news -->
146
        [% ELSE %] <!-- koha news -->
150
            [% IF Koha.Preference( 'OpacNewsLibrarySelect' ) %]
147
            [% IF Koha.Preference( 'OpacNewsLibrarySelect' ) %]
151
                <div id="news" class="newscontainer">
148
                <div id="news" class="newscontainer">
(-)a/opac/opac-main.pl (-22 / +3 lines)
Lines 58-83 elsif (C4::Context->userenv and defined $input->param('branch') and length $inpu Link Here
58
   $homebranch = "";
58
   $homebranch = "";
59
}
59
}
60
60
61
my $news_id = $input->param('news_id');
62
my $koha_news;
63
61
64
if (defined $news_id){
62
my $news_id = $input->param('news_id');
65
    $koha_news = Koha::AdditionalContents->search({ idnew => $news_id, location => ['opac_only', 'staff_and_opac'] }); # get news that is not staff-only news
63
$template->param( news_id => $news_id );
66
    if ( $koha_news->count > 0){
67
        $template->param( news_item => $koha_news->next );
68
    } else {
69
        $template->param( single_news_error => 1 );
70
    }
71
} else {
72
    $koha_news = Koha::AdditionalContents->search_for_display(
73
        {
74
            category   => 'news',
75
            location   => ['opac_only', 'staff_and_opac'],
76
            lang       => $template->lang,
77
            library_id => $homebranch,
78
        }
79
    );
80
}
81
64
82
# For dashboard
65
# For dashboard
83
my $patron = Koha::Patrons->find( $borrowernumber );
66
my $patron = Koha::Patrons->find( $borrowernumber );
Lines 108-116 if ( $patron ) { Link Here
108
    }
91
    }
109
}
92
}
110
93
94
$template->param( branchcode => $homebranch ) if $homebranch;
111
$template->param(
95
$template->param(
112
    koha_news           => $koha_news,
113
    branchcode          => $homebranch,
114
    daily_quote         => Koha::Quotes->get_daily_quote(),
96
    daily_quote         => Koha::Quotes->get_daily_quote(),
115
);
97
);
116
98
117
- 

Return to bug 29691