Bug 29691: Use template to display news on opac homepage
[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 AdditionalContents %]
8 [% USE AuthClient %]
9 [% PROCESS 'i18n.inc' %]
10 [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
11 [% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
12 [% SET OpacNavRight = AdditionalContents.get( location => "OpacNavRight", lang => lang, library => logged_in_user.branchcode || default_branch ) %]
13 [% SET OpacMainUserBlock = AdditionalContents.get( location => "OpacMainUserBlock", lang => lang, library => logged_in_user.branchcode || default_branch ) %]
14 [% SET OpacLoginInstructions = AdditionalContents.get( location => "OpacLoginInstructions", lang => lang, library => branchcode || default_branch ) %]
15 [% INCLUDE 'doc-head-open.inc' %]
16 <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
17 [% INCLUDE 'doc-head-close.inc' %]
18 [% BLOCK cssinclude %][% END %]
19 </head>
20 [% INCLUDE 'bodytag.inc' bodyid='opac-main' %]
21 [% INCLUDE 'masthead.inc' %]
22
23 <div class="main">
24     <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumbs">
25         <ol class="breadcrumb">
26             [% IF news_item %]
27                 <li class="breadcrumb-item">
28                     <a href="/cgi-bin/koha/opac-main.pl">Home</a>
29                 </li>
30                 <li class="breadcrumb-item active">
31                     <a href="#" aria-current="page">[% news_item.title | html %]</a>
32                 </li>
33             [% ELSE %]
34                 <li class="breadcrumb-item active">
35                     <a href="#" aria-current="page">Home</a>
36                 </li>
37             [% END %]
38         </ol>
39     </nav> <!-- /#breadcrumbs -->
40
41     [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
42         [% IF ( loggedinusername ) %]
43             <div id="loggedin" class="container-fluid">
44         [% ELSE %]
45             <div id="notloggedin" class="container-fluid">
46         [% END %]
47     [% ELSE %]
48         <div id="notloggedin" class="container-fluid">
49     [% END %]
50
51     <div class="row">
52         [% IF ( OpacNav ||  OpacNavBottom ) %]
53             <div class="col-12 col-lg-2 order-3 order-lg-1">
54                 <div id="navigation">
55                     [% INCLUDE 'navigation.inc' %]
56                 </div>
57             </div>
58         [% END %]
59
60         [% IF ( OpacNav ||  OpacNavBottom  ) && (Koha.Preference( 'opacuserlogin' ) == 1 || OpacNavRight) %]
61             [% #  Three-column layout with right and left sidebars %]
62             <div class="col-12 col-lg-7 order-md-1 maincontent">
63         [% ELSIF (Koha.Preference( 'opacuserlogin' ) == 1 || OpacNavRight) %]
64             [% #  Two-column layout with right sidebar %]
65             <div class="col-12 col-lg-9 order-md-1 maincontent">
66         [% ELSIF ( OpacNav ||  OpacNavBottom  ) %]
67             <div class="col-12 col-lg-10 order-md-1 maincontent">
68         [% ELSE %]
69             <div class="col order-md-1 maincontent">
70         [% END %]
71
72         <h1 class="sr-only">Koha home</h1>
73
74         [% IF Koha.Preference( 'OpacNewsLibrarySelect' ) %]
75             [% UNLESS news_id %]
76                 <form id="news-branch-select" class="form-inline" name="news-branch-select" method="get" action="/cgi-bin/koha/opac-main.pl">
77                     <legend class="sr-only">News</legend>
78                     <label for="news-branch">Display news for: </label>
79                     <select id="news-branch" name="branch">
80                         [% IF ( branchcode == "" ) %]
81                             <option value="" selected="selected">System-wide only</option>
82                         [% ELSE %]
83                             <option value="">System-wide only</option>
84                         [% END %]
85                         [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode, unfiltered => 1, ) %]
86                     </select>
87                 </form>
88             [% END %]
89         [% END %]
90
91         [% IF news_id %]
92             [% SET koha_news = AdditionalContents.get_opac_news_by_id( news_id => news_id ) %]
93         [% ELSE %]
94             [% SET koha_news = AdditionalContents.get( category => 'news', location => ['opac_only', 'staff_and_opac'], lang => lang, library => branchcode ) %]
95         [% END %]
96         [% IF koha_news.content.count %]
97             <div id="news" class="newscontainer">
98                 [% SET show_author = Koha.Preference('NewsAuthorDisplay') == 'opac' || Koha.Preference('NewsAuthorDisplay') == 'both' %]
99                 [% FOREACH koha_new IN koha_news.content %]
100                     <div class="newsitem">
101                         <h4 class="newsheader">
102                             [% IF ( news_item ) %]
103                                 [% koha_new.title | html %]
104                             [% ELSE %]
105                                 <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>
106                             [% END %]
107                         </h4>
108                         <div class="newsbody">[% koha_new.content | $raw %]</div>
109                         <div class="newsfooter">
110                             Published on [% koha_new.published_on | $KohaDates %]
111                             [% IF ( show_author && koha_new.author ) %]
112                                 by <span class="newsauthor">[% INCLUDE 'patron-title.inc' patron=koha_new.author %]</span>
113                             [% END %]
114                             [% IF ( news_id ) %]
115                                 &bull; <a href="/cgi-bin/koha/opac-main.pl">Show all news</a>
116                             [% END %]
117                         </div>
118                     </div>
119                 [% END %]
120
121                 [% UNLESS news_id %]
122                     <div id="rssnews-container">
123                         <!-- Logged in users have a branch code or it could be explicitly set -->
124                         <a href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-news-rss.pl?branchcode=[% branchcode | uri %]">
125                             <i class="fa fa-rss" aria-hidden="true"></i>
126                             [% IF Branches.all.size == 1 %]
127                                 [% IF branchcode %]
128                                     <span>RSS feed for [% Branches.GetName( branchcode ) | html %] library news</span>
129                                 [% ELSE %]
130                                     <span>RSS feed for library news</span>
131                                 [% END %]
132                             [% ELSE %]
133                                 [% IF branchcode %]
134                                     <span>RSS feed for [% Branches.GetName( branchcode ) | html %] and system-wide library news</span>
135                                 [% ELSE %]
136                                     <span>RSS feed for system-wide library news</span>
137                                 [% END %]
138                             [% END %]
139                         </a>
140                     </div>
141                 [% END %]
142             </div>
143         [% ELSIF news_id %] <!-- news_id but no koha_news.content -->
144             <div class="alert alert-error">
145                 This news item does not exist.
146             </div>
147         [% ELSE %] <!-- koha news -->
148             [% IF Koha.Preference( 'OpacNewsLibrarySelect' ) %]
149                 <div id="news" class="newscontainer">
150                     <div class="newsitem">
151                         <div class="newsbody">No news to display.</div>
152                         <div class="newsfooter"></div>
153                     </div>
154                 </div>
155             [% END %]
156
157         [% END # IF koha_news %]
158
159         [% UNLESS news_item # Don't show under single news item %]
160             [% IF ( daily_quote ) %]
161                 <div id="daily-quote">
162                     <h2>Quote of the day</h2>
163                     <div>
164                         <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>
165                     </div>
166                 </div>
167             [% END %]
168
169             [% IF ( OpacMainUserBlock ) %]
170                 [% PROCESS koha_news_block news => OpacMainUserBlock %]
171             [% END %]
172         [% END %]
173
174         </div> <!-- / .col 6/8 -->
175
176         [% IF ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) || OpacNavRight ) %]
177             <div class="col-12 col-lg-3 order-md-2">
178                 [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
179                     [% UNLESS ( loggedinusername ) %]
180                         [% UNLESS ( casAuthentication || shibbolethAuthentication || Koha.Preference('opacShibOnly') ) %]
181                             <div id="login">
182                                 <form action="/cgi-bin/koha/opac-user.pl" method="post" name="auth" id="auth" autocomplete="off">
183                                     <input type="hidden" name="koha_login_context" value="opac" />
184                                     <fieldset class="brief">
185                                         <legend>Log in to your account:</legend>
186                                         [% IF ( Koha.Preference('GoogleOpenIDConnect') == 1 ) %]
187                                             <a href="/cgi-bin/koha/svc/auth/googleopenidconnect" class="btn btn-light" id="openid_connect"><i class="fa-brands fa-google" aria-hidden="true"></i> Log in with Google</a>
188                                             <p>If you do not have a Google account, but do have a local account, you can still log in: </p>
189                                         [% END # /IF GoogleOpenIDConnect %]
190                                         [% SET identity_providers = AuthClient.get_providers('opac') %]
191                                         [% IF ( ! identity_providers.empty ) %]
192                                             [% FOREACH provider IN identity_providers %]
193                                                 <p class="clearfix">
194                                                     <a href="[% provider.url | url %]" class="btn btn-light col-md-12" id="provider_[% provider.code | html %]">
195                                                         [% IF provider.icon_url %]
196                                                         <img src="[% provider.icon_url | url %]"  style="max-height: 20px; max-width: 20px;"/>
197                                                         [% ELSE %]
198                                                         <i class="fa fa-user" aria-hidden="true"></i>
199                                                         [% END %]
200                                                         Log in with [% provider.description | html %]
201                                                     </a>
202                                                 </p>
203                                             [% END %]
204                                             <hr/>
205                                             <p>If you do not have an external account, but do have a local account, you can still log in: </p>
206                                         [% END # /IF  identity_providers.size %]
207                                         <div class="local-login">
208                                             <label for="userid">Login:</label>
209                                             <input class="form-control" type="text" id="userid" name="userid" autocomplete="off" />
210                                             <label for="password">Password:</label>
211                                             <input class="form-control" type="password" id="password" name="password" autocomplete="off" />
212                                             <fieldset class="action">
213                                                 <input type="submit" value="Log in" class="btn btn-primary" />
214                                             </fieldset>
215                                         </div>
216                                         [% IF ( OpacLoginInstructions ) %]
217                                             <div id="nologininstructions-main" class="nologininstructions">
218                                                 [% PROCESS koha_news_block news => OpacLoginInstructions %]
219                                             </div>
220                                         [% END %]
221                                         [% IF Koha.Preference('OpacPasswordChange') && Categories.can_any_reset_password %]
222                                             <div id="forgotpassword-main" class="forgotpassword">
223                                                 <p><a href="/cgi-bin/koha/opac-password-recovery.pl">Forgot your password?</a></p>
224                                             </div>
225                                         [% END %]
226                                         [% IF PatronSelfRegistration && PatronSelfRegistrationDefaultCategory %]
227                                             <div id="patronregistration-main" class="patronregistration">
228                                                 <p>Don't have an account? <a href="/cgi-bin/koha/opac-memberentry.pl">Register here.</a></p>
229                                             </div>
230                                         [% END %]
231                                     </fieldset>
232                                 </form>
233                             </div> <!-- /#login -->
234                         [% END # /casAuthentication %]
235                     [% ELSE %]
236                         [% IF Koha.Preference('OPACUserSummary') && dashboard_info %]
237                             <div id="user_summary">
238                                 <h2>User summary</h2>
239                                 <p>Welcome, <a href="/cgi-bin/koha/opac-user.pl"><span class="loggedinusername">[% INCLUDE 'patron-title.inc' patron = logged_in_user %]</span></a></p>
240                                 <ul id="user_summary_shortcuts">
241                                     [% IF checkouts && checkouts > 0 %]
242                                         <li>
243                                             <a href="/cgi-bin/koha/opac-user.pl#opac-user-checkouts">
244                                                 <span class="user_checkouts_count count_label">[% checkouts | html %]</span>
245                                                 [% tn('checkout', 'checkouts', checkouts ) | html %]
246                                             </a>
247                                         </li>
248                                     [% END %]
249                                     [% IF overdues && overdues > 0 %]
250                                         <li>
251                                             <a href="/cgi-bin/koha/opac-user.pl#opac-user-overdues">
252                                                 <span class="user_overdues_count count_label">[% overdues | html %]</span>
253                                                 [% tn('overdue', 'overdues', overdues ) | html %]
254                                             </a>
255                                         </li>
256                                     [% END %]
257                                     [% IF holds_pending && holds_pending > 0 %]
258                                         <li>
259                                             <a href="/cgi-bin/koha/opac-user.pl#opac-user-holds">
260                                                 <span class="user_holds_pending_count count_label">[% holds_pending | html %]</span>
261                                                 [% tn('hold pending', 'holds pending', holds_pending ) | html %]
262                                             </a>
263                                         </li>
264                                     [% END %]
265                                     [% IF holds_waiting && holds_waiting > 0 %]
266                                         <li>
267                                             <a href="/cgi-bin/koha/opac-user.pl#opac-user-holds">
268                                                 <span class="user_holds_waiting_count count_label">[% holds_waiting | html %]</span>
269                                                 [% tn('hold waiting', 'holds waiting', holds_waiting ) | html %]
270                                             </a>
271                                         </li>
272                                     [% END %]
273                                     [% IF total_owing && total_owing > 0 %]
274                                         <li>
275                                             <a href="/cgi-bin/koha/opac-account.pl">
276                                                 <span class="user_fines_count count_label">[% total_owing | $Price with_symbol => 1 %]</span>
277                                                 due in fines and charges
278                                             </a>
279                                         </li>
280                                     [% END %]
281                                     [% IF patron_messages && patron_messages.filter_by_unread.count > 0 || opacnote %]
282                                         [% IF opacnote %]
283                                             <li>
284                                                 <a href="/cgi-bin/koha/opac-user.pl">
285                                                     <span class="count_label">[% patron_messages.filter_by_unread.count + 1 | html %]</span>
286                                                     [% tn('message', 'messages', patron_messages.filter_by_unread.count + 1 ) | html %]
287                                                 </a>
288                                             </li>
289                                         [% ELSE %]
290                                             <li>
291                                                 <a href="/cgi-bin/koha/opac-user.pl">
292                                                     <span class="count_label">[% patron_messages.filter_by_unread.count | html %]</span>
293                                                     [% tn('message', 'messages', patron_messages.filter_by_unread.count ) | html %]
294                                                 </a>
295                                             </li>
296                                         [% END %]
297                                     [% END %]
298                                     [% IF savings %]
299                                         <li>
300                                             <a href="/cgi-bin/koha/opac-user.pl">
301                                                 <span class="count_label">[% savings | $Price with_symbol => 1 %]</span>
302                                                 total savings
303                                             </a>
304                                         </li>
305                                     [% END %]
306                                 </ul>
307                             </div>
308                         [% END %]
309                     [% END # /loggedinusername %]
310                 [% END # /opacuserlogin %]
311                 [% PROCESS koha_news_block news => OpacNavRight %]
312             </div> <!-- / .col -->
313         [% END # /opacuserlogin || OpacNavRight %]
314
315         </div> <!-- /.container-fluid -->
316     </div> <!-- /.row -->
317 </div> <!-- /.main -->
318
319 [% INCLUDE 'opac-bottom.inc' %]
320 [% BLOCK jsinclude %][% END %]