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

(-)a/opac/opac-page.pl (-7 / +8 lines)
Lines 19-24 use Modern::Perl; Link Here
19
19
20
use CGI qw ( -utf8 );
20
use CGI qw ( -utf8 );
21
use C4::Auth qw( get_template_and_user );
21
use C4::Auth qw( get_template_and_user );
22
use C4::Languages qw(getlanguage);
22
use C4::Output qw( output_html_with_http_headers );
23
use C4::Output qw( output_html_with_http_headers );
23
use Koha::AdditionalContents;
24
use Koha::AdditionalContents;
24
25
Lines 34-39 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
34
);
35
);
35
36
36
my $page_id = $query->param('page_id');
37
my $page_id = $query->param('page_id');
38
my $code = $query->param('code');
37
my $page;
39
my $page;
38
40
39
my $homebranch = $ENV{OPAC_BRANCH_DEFAULT};
41
my $homebranch = $ENV{OPAC_BRANCH_DEFAULT};
Lines 41-53 if (C4::Context->userenv) { Link Here
41
    $homebranch = C4::Context->userenv->{'branch'};
43
    $homebranch = C4::Context->userenv->{'branch'};
42
}
44
}
43
45
44
if (defined $page_id){
46
if( $page_id ) {
45
    $page = Koha::AdditionalContents->search({ idnew => $page_id, location => ['opac_only', 'staff_and_opac'], branchcode => [ $homebranch, undef ] });
47
    $page = Koha::AdditionalContents->search({ idnew => $page_id, location => ['opac_only', 'staff_and_opac'], branchcode => [ $homebranch, undef ] });
46
    if ( $page->count > 0){
48
} elsif( $code ) {
47
        $template->param( page => $page->next );
49
    my $lang = $query->param('lang') || C4::Languages::getlanguage($query); # URL param overrides getlanguage
48
    } else {
50
    # In the next query we make sure that the 'default' records come after the regular languages
49
        $template->param( page_error => 1 );
51
    $page = Koha::AdditionalContents->search({ code => $code, lang => ['default', $lang], location => ['opac_only', 'staff_and_opac'], branchcode => [ $homebranch, undef ] }, { order_by => { -desc => \[ 'CASE WHEN lang="default" THEN "" ELSE lang END' ]}} );
50
    }
51
}
52
}
53
$template->param( $page && $page->count ? ( page => $page->next ) : ( page_error => 1 ) );
52
54
53
output_html_with_http_headers $query, $cookie, $template->output;
55
output_html_with_http_headers $query, $cookie, $template->output;
54
- 

Return to bug 31385