+#Search for title in links
+my $marccontrolnumber = GetMarcControlnumber ($record, $marcflavour);
+
+if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
+ $dat->{author} ? $search_for_title =~ s/{AUTHOR}/$dat->{author}/g : $search_for_title =~ s/{AUTHOR}//g;
+ $dat->{title} =~ s/\/+$//; # remove trailing slash
+ $dat->{title} =~ s/\s+$//; # remove trailing space
+ $dat->{title} ? $search_for_title =~ s/{TITLE}/$dat->{title}/g : $search_for_title =~ s/{TITLE}//g;
+ $isbn ? $search_for_title =~ s/{ISBN}/$isbn/g : $search_for_title =~ s/{ISBN}//g;
+ $marccontrolnumber ? $search_for_title =~ s/{CONTROLNUMBER}/$marccontrolnumber/g : $search_for_title =~ s/{CONTROLNUMBER}//g;
+ $template->param('OPACSearchForTitleIn' => $search_for_title);
+}
+
+# We try to select the best default tab to show, according to what
+# the user wants, and what's available for display
+my $opac_serial_default = C4::Context->preference('opacSerialDefaultTab');
+my $defaulttab =
+ $opac_serial_default eq 'subscriptions' && $subscriptionsnumber
+ ? 'subscriptions' :
+ $opac_serial_default eq 'serialcollection' && @serialcollections > 0
+ ? 'serialcollection' :
+ $opac_serial_default eq 'holdings' && $dat->{'count'} > 0
+ ? 'holdings' :
+ $subscriptionsnumber
+ ? 'subscriptions' :
+ @serialcollections > 0
+ ? 'serialcollection' : 'subscription';
+$template->param('defaulttab' => $defaulttab);
+