Bug 24398: Fix 500 when viewing a single news item at the OPAC
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-main.tt
1 [% USE raw %]
2 [% USE Koha %]
3 [% USE KohaDates %]
4 [% USE Branches %]
5 [% USE Categories %]
6 [% USE Price %]
7 [% USE KohaNews %]
8 [% SET OpacNavRight = KohaNews.get( location => "OpacNavRight", lang => lang, library => branchcode ) %]
9 [% SET OpacMainUserBlock = KohaNews.get( location => "OpacMainUserBlock", lang => lang, library => branchcode ) %]
10 [% SET OpacLoginInstructions = KohaNews.get( location => "OpacLoginInstructions", lang => lang, library => branchcode ) %]
11 [% INCLUDE 'doc-head-open.inc' %]
12 <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
13 [% INCLUDE 'doc-head-close.inc' %]
14 [% BLOCK cssinclude %][% END %]
15 </head>
16 [% INCLUDE 'bodytag.inc' bodyid='opac-main' %]
17 [% INCLUDE 'masthead.inc' %]
18
19 <div class="main">
20     <nav aria-label="breadcrumb">
21         <ul class="breadcrumb">
22             [% IF news_item %]
23                 <li class="breadcrumb-item">
24                     <a href="/cgi-bin/koha/opac-main.pl">Home</a>
25                 </li>
26                 <li class="breadcrumb-item active" aria-current="page">
27                     [% news_item.title | html %]
28                 </li>
29             [% ELSE %]
30                 <li class="breadcrumb-item active" aria-current="page">
31                     <a href="/cgi-bin/koha/opac-main.pl">Home</a>
32                 </li>
33             [% END %]
34         </ul>
35     </nav>
36
37     [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
38         [% IF ( loggedinusername ) %]
39             <div id="loggedin" class="container-fluid">
40         [% ELSE %]
41             <div id="notloggedin" class="container-fluid">
42         [% END %]
43     [% ELSE %]
44         <div id="notloggedin" class="container-fluid">
45     [% END %]
46
47     <div class="row">
48         [% IF ( OpacNav ||  OpacNavBottom ) %]
49             <div class="col-12 col-lg-2 order-3 order-lg-1">
50                 <div id="navigation">
51                     [% INCLUDE 'navigation.inc' %]
52                 </div>
53             </div>
54         [% END %]
55
56         [% IF ( OpacNav ||  OpacNavBottom  ) && (Koha.Preference( 'opacuserlogin' ) == 1 || OpacNavRight) %]
57             [% #  Three-column layout with right and left sidebars %]
58             <div class="col-12 col-lg-7 order-md-1 maincontent">
59         [% ELSIF (Koha.Preference( 'opacuserlogin' ) == 1 || OpacNavRight) %]
60             [% #  Two-column layout with right sidebar %]
61             <div class="col-12 col-lg-9 order-md-1 maincontent">
62         [% ELSIF ( OpacNav ||  OpacNavBottom  ) %]
63             <div class="col-12 col-lg-10 order-md-1 maincontent">
64         [% ELSE %]
65             <div class="col order-md-1 maincontent">
66         [% END %]
67
68         [% IF Koha.Preference( 'OpacNewsLibrarySelect' ) %]
69             [% UNLESS news_item %]
70                 <form id="news-branch-select" class="form-inline" name="news-branch-select" method="get" action="/cgi-bin/koha/opac-main.pl">
71                     <label for="news-branch">Display news for: </label>
72                     <select id="news-branch" name="branch">
73                         [% IF ( branchcode == "" ) %]
74                             <option value="" selected="selected">System-wide only</option>
75                         [% ELSE %]
76                             <option value="">System-wide only</option>
77                         [% END %]
78                         [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode, unfiltered => 1, ) %]
79                     </select>
80                 </form>
81             [% END %]
82         [% END %]
83
84         [% IF ( koha_news ) %]
85
86             [% IF single_news_error %]
87
88                 <div class="alert alert-error">
89                     This news item does not exist.
90                 </div>
91
92             [% ELSE %]
93
94                 <div id="news" class="newscontainer">
95                     [% SET newsdisp = ( Koha.Preference('NewsAuthorDisplay') ) %]
96                     [% FOREACH koha_new IN koha_news %]
97                         <div class="newsitem">
98                             <h4 class="newsheader">
99                                 [% IF ( news_item ) %]
100                                     [% koha_new.title | html %]
101                                 [% ELSE %]
102                                     <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>
103                                 [% END %]
104                             </h4>
105                             <div class="newsbody">[% koha_new.content | $raw %]</div>
106                             <div class="newsfooter">
107                                 Published on [% koha_new.published_on | $KohaDates %]
108                                 [% IF ( (newsdisp == 'opac' || newsdisp == 'both') && koha_new.borrowernumber ) %]
109                                     [% IF news_item %]
110                                         [% SET author = koha_new.author %]
111                                         by <span class="newsauthor_title">[% author.title | html %] </span>[% author.firstname | html %] [% author.surname | html %]
112                                     [% ELSE %]
113                                         by <span class="newsauthor_title">[% koha_new.author_title | html %] </span>[% koha_new.author_firstname | html %] [% koha_new.author_surname | html %]
114                                     [% END %]
115                                 [% END %]
116                                 [% IF ( news_item ) %]
117                                     &bull; <a href="/cgi-bin/koha/opac-main.pl">Show all news</a>
118                                 [% END %]
119                             </div>
120                         </div>
121
122                     [% END %]
123                     [% UNLESS news_item %]
124                         <div id="rssnews-container">
125                             <!-- Logged in users have a branch code or it could be explicitly set -->
126                             <a href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-news-rss.pl?branchcode=[% branchcode | uri %]">
127                                 <i class="fa fa-rss" aria-hidden="true"></i>
128                                 [% IF Branches.all.size == 1 %]
129                                     [% IF branchcode %]
130                                         RSS feed for [% Branches.GetName( branchcode ) | html %] library news
131                                     [% ELSE %]
132                                         RSS feed for library news
133                                     [% END %]
134                                 [% ELSE %]
135                                     [% IF branchcode %]
136                                         RSS feed for [% Branches.GetName( branchcode ) | html %] and system-wide library news
137                                     [% ELSE %]
138                                         RSS feed for system-wide library news
139                                     [% END %]
140                                 [% END %]
141                             </a>
142                         </div>
143                     [% END %]
144                 </div>
145
146             [% END # /IF single_news_error %]
147
148         [% ELSE %] <!-- koha news -->
149             [% IF Koha.Preference( 'OpacNewsLibrarySelect' ) %]
150                 <div id="news" class="newscontainer">
151                     <div class="newsitem">
152                         <div class="newsbody">No news to display.</div>
153                         <div class="newsfooter"></div>
154                     </div>
155                 </div>
156             [% END %]
157
158         [% END # IF koha_news %]
159
160         [% UNLESS news_item # Don't show under single news item %]
161             [% IF ( daily_quote ) %]
162                 <div id="daily-quote">
163                     <h3>Quote of the day</h3>
164                     <div>
165                         <span id="daily-quote-text">[% daily_quote.text | html %]</span><span id="daily-quote-sep"> ~ </span><span id="daily-quote-source">[% daily_quote.source | html %]</span>
166                     </div>
167                 </div>
168             [% END %]
169
170             [% IF ( OpacMainUserBlock ) %]
171                 <div id="opacmainuserblock">
172                     [% PROCESS koha_news_block news => OpacMainUserBlock %]
173                 </div>
174             [% END %]
175         [% END %]
176
177         </div> <!-- / .col 6/8 -->
178
179         [% IF ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) || OpacNavRight ) %]
180             <div class="col-12 col-lg-3 order-md-2">
181                 [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
182                     [% UNLESS ( loggedinusername ) %]
183                         [% UNLESS ( casAuthentication || shibbolethAuthentication ) %]
184                             <div id="login">
185                                 <form action="/cgi-bin/koha/opac-user.pl" method="post" name="auth" id="auth" autocomplete="off">
186                                     <input type="hidden" name="koha_login_context" value="opac" />
187                                     <fieldset class="brief">
188                                         <legend>Log in to your account:</legend>
189                                         <label for="userid">Login:</label>
190                                         <input class="form-control" type="text" id="userid" name="userid" />
191                                         <label for="password">Password:</label>
192                                         <input class="form-control" type="password" id="password" name="password" />
193                                         <fieldset class="action">
194                                             <input type="submit" value="Log in" class="btn btn-primary" />
195                                         </fieldset>
196                                         [% IF ( OpacLoginInstructions ) %]
197                                             <div id="nologininstructions-main" class="nologininstructions">
198                                                 [% PROCESS koha_news_block news => OpacLoginInstructions %]
199                                             </div>
200                                         [% END %]
201                                         [% IF Koha.Preference('OpacPasswordChange') && Categories.can_any_reset_password %]
202                                             <div id="forgotpassword-main" class="forgotpassword">
203                                                 <p><a href="/cgi-bin/koha/opac-password-recovery.pl">Forgot your password?</a></p>
204                                             </div>
205                                         [% END %]
206                                         [% IF PatronSelfRegistration && PatronSelfRegistrationDefaultCategory %]
207                                             <div id="patronregistration-main" class="patronregistration">
208                                                 <p>Don't have an account? <a href="/cgi-bin/koha/opac-memberentry.pl">Register here.</a></p>
209                                             </div>
210                                         [% END %]
211                                     </fieldset>
212                                 </form>
213                             </div> <!-- /#login -->
214                         [% END # /casAuthentication %]
215                     [% ELSE %]
216                         [% IF Koha.Preference('OPACUserSummary') && dashboard_info %]
217                             <div id="user_summary">
218                                 <h3>Welcome, <a href="/cgi-bin/koha/opac-user.pl"><span class="loggedinusername">[% INCLUDE 'patron-title.inc' patron = logged_in_user %]</span></a></h3>
219                                 <ul id="user_summary_shortcuts">
220                                     [% IF checkouts && checkouts > 0 %]
221                                         <li><a href="/cgi-bin/koha/opac-user.pl#opac-user-checkouts"><span class="user_checkouts_count count_label">[% checkouts | html %]</span> checkout(s)</a></li>
222                                     [% END %]
223                                     [% IF overdues && overdues > 0 %]
224                                         <li><a href="/cgi-bin/koha/opac-user.pl#opac-user-overdues"><span class="user_overdues_count count_label">[% overdues | html %]</span> overdue(s)</a></li>
225                                     [% END %]
226                                     [% IF holds_pending && holds_pending > 0 %]
227                                         <li><a href="/cgi-bin/koha/opac-user.pl#opac-user-holds"><span class="user_holds_pending_count count_label">[% holds_pending | html %]</span> hold(s) pending</a></li>
228                                     [% END %]
229                                     [% IF holds_waiting && holds_waiting > 0 %]
230                                         <li><a href="/cgi-bin/koha/opac-user.pl#opac-user-holds"><span class="user_holds_waiting_count count_label">[% holds_waiting | html %]</span> hold(s) waiting</a></li>
231                                     [% END %]
232                                     [% IF total_owing && total_owing > 0 %]
233                                         <li><a href="/cgi-bin/koha/opac-account.pl"><span class="user_fines_count count_label">[% total_owing | $Price with_symbol => 1 %]</span> due in fines and charges</a></li>
234                                     [% END %]
235                                 </ul>
236                             </div>
237                         [% END %]
238                     [% END # /loggedinusername %]
239                 [% END # /opacuserlogin %]
240                 [% PROCESS koha_news_block news => OpacNavRight %]
241             </div> <!-- / .col -->
242         [% END # /opacuserlogin || OpacNavRight %]
243
244         </div> <!-- /.container-fluid -->
245     </div> <!-- /.row -->
246 </div> <!-- /.main -->
247
248 [% INCLUDE 'opac-bottom.inc' %]
249 [% BLOCK jsinclude %][% END %]