Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Different template

Quote Reply
Different template
how do i tell a search to use a differant template to show the results rather than the default template ie is there a template=another.html command i can use?

Best Regards
Marc P Summers
Canterbury City Council
Quote Reply
Re: Different template In reply to
ok i have cracked it
the template i wanted to use is called search_results_firstaid.html

I edited Home.pm
with the following

$COMPILE{search_results_firstaid} = <<'END_OF_SUB';
sub search_results_firstaid {
my($self) = shift;
return $self->home($self->_language('PER_VIEW')) unless ($self->{user}->{view_p});
# Make sure the user passed in some values to search on
$self->_check_opts or return $self->search_form ($self->_language('SRC_FAILURE'));
# Format the cgi for searching
# Check if users can view only their own record
if ($self->{cfg}->{'auth_view_own'} and $self->{cfg}->{'auth_user_field'}) {
$self->{cgi}->{$self->{cfg}->{'auth_user_field'}}= $self->{user}->{'Username'};
# Do the search and count the results.
my $sth = $self->{db}->query_sth ($self->{cgi}) or return $self->search_form ($GT::SQL::error);
my $hits = $self->{db}->hits();
# Return if we haven't found anything.
if ($hits == 0) {
return $self->search_form ($self->_language('SRC_NOTFOUND'));
# Build speed bar
my $speedbar = '';
if ($hits > ($self->{cgi}->{mh} || 25)) {
my $name = GT::CGI->url;
$speedbar .= $self->{disp}->toolbar( $self->{cgi}->{nh} || 1, $self->{cgi}->{mh} || 25, $hits, $name);
# Return results
my (@output);
while (my $row = $sth->fetchrow_hashref) {
# pls correct the path to the photo path by setting image_path in ConfigData.pm to display image correctly
push @output, $row;
$self->print ('search_results_firstaid.html',{
header => $self->_language('HEA_SRC_RESULT'),
results => \@output,
speedbar=> $speedbar,
msg => $self->_language('SRC_RESULT',$hits)});

then added do=search_results_firstaid to my search form

Hey Presto - it worked

Best Regards
Marc P Summers
Canterbury City Council