Gossamer Forum
Home : Products : Links 2.0 : Customization :

Does anyone know what is wrong here???

Quote Reply
Does anyone know what is wrong here???
Hi I am customising site_html_templates.pl -- sub site_html_print_cat . What I want to do is add an appropriate image at the side of each category and I am using the following code so far:

if ($category_name =~ "Books")

{

$output .= qq| <IMG SRC="/images/bookslogo.gif" BORDER="0"><a class="link" href="$url">$category_name</a> |;

$output .= qq|<small><sup class="new">new</sup></small>| if (&days_old($mod) < $db_new_cutoff);

$output .= qq|</dt>|;

$output .= qq|<dd><span class="descript">$description </span></dd>| if (!($description =~ /^[\s\n]*$/));

$output .= qq|</dl>|;

}

elsif ($category_name =~ "Childrens")

{

$output .= qq| <IMG SRC="/images/bookslogo.gif" BORDER="0"><a class="link" href="$url">$category_name</a> |;

$output .= qq|<small><sup class="new">new</sup></small>| if (&days_old($mod) < $db_new_cutoff);

$output .= qq|</dt>|;

$output .= qq|<dd><span class="descript">$description </span></dd>| if (!($description =~ /^[\s\n]*$/));

$output .= qq|</dl>|;

}

elsif ($category_name =~ "Computer_Games")

{

$output .= qq| <IMG SRC="/images/bookslogo.gif" BORDER="0"><a class="link" href="$url">$category_name</a> |;

$output .= qq|<small><sup class="new">new</sup></small>| if (&days_old($mod) < $db_new_cutoff);

$output .= qq|</dt>|;

$output .= qq|<dd><span class="descript">$description </span></dd>| if (!($description =~ /^[\s\n]*$/));

$output .= qq|</dl>|;

}

elsif ($category_name =~ "Computers")

{

$output .= qq| <IMG SRC="/images/bookslogo.gif" BORDER="0"><a class="link" href="$url">$category_name</a> |;

$output .= qq|<small><sup class="new">new</sup></small>| if (&days_old($mod) < $db_new_cutoff);

$output .= qq|</dt>|;

$output .= qq|<dd><span class="descript">$description </span></dd>| if (!($description =~ /^[\s\n]*$/));

$output .= qq|</dl>|;

}

else

{

$output .= qq|<dl><dt><strong><a class="link" href="$url">$category_name</a></strong>|;

$output .= qq|<small><sup class="new">new</sup></small>| if (&days_old($mod) < $db_new_cutoff);

$output .= qq|</dt>|;

$output .= qq|<dd><span class="descript">$description </span></dd>| if (!($description =~ /^[\s\n]*$/));

$output .= qq|</dl>|;

}



Now this code works fine for any category which is a single word - However, it does not work for Computer_Games. Does anyone have any idea what I am doing wrong? Do I need to urlencode the underscore or what??

Any help would be greatly appreciated.

Advanced Thanks.




Quote Reply
Re: [Ashy2000] Does anyone know what is wrong here??? In reply to
You are half way between using a regex and a basic comparison. You either need:

if ($category_name eq "whatever") {

or

if ($category_name =~ /^whatever$/) {

Last edited by:

Paul: Dec 5, 2002, 6:04 AM
Quote Reply
Re: [Paul] Does anyone know what is wrong here??? In reply to
Tried both the above methods and it still doesn't work.
Quote Reply
Re: [Ashy2000] Does anyone know what is wrong here??? In reply to
They work if there is a match so it looks like the problem is somewhere else in the code.
Quote Reply
Re: [Paul] Does anyone know what is wrong here??? In reply to
elsif ($category_name =~ /^Computer_Games$/)

is that how it would find a category called Computer_Games ?? Have I done it right?


Quote Reply
Re: [Ashy2000] Does anyone know what is wrong here??? In reply to
you probably want:
Code:
/^Computer_Games(\/.+)?/
if you intend on matching subcategories as well.

Philip
------------------
Limecat is not pleased.