+if ( ! $record ) {
+ print $query->redirect("/cgi-bin/koha/errors/404.pl");
+ exit;
+}
+
+unless ( $patron and $patron->category->override_hidden_items ) {
+ # only skip this check if there's a logged in user
+ # and its category overrides OpacHiddenItems
+ if ( $biblio->hidden_in_opac({ rules => C4::Context->yaml_preference('OpacHiddenItems') }) ) {
+ print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early
+ exit;
+ }
+}
+
+my $items = $biblio->items->filter_by_visible_in_opac({ patron => $patron });
+my $framework = $biblio ? $biblio->frameworkcode : q{};
+my $tagslib = &GetMarcStructure( 0, $framework );
+
+my $record_processor = Koha::RecordProcessor->new({
+ filters => [ 'EmbedItems', 'ViewPolicy' ],
+ options => {
+ interface => 'opac',
+ frameworkcode => $framework,
+ items => [ $items->as_list ],
+ }
+});
+$record_processor->process($record);