Gossamer Forum
Home : Products : Links 2.0 : Customization :

A couple of questions

Quote Reply
A couple of questions
#1 - How do you make reference to a filed in categories.db in site_html.pl?

#2 - Is it possible to have for an if clause, two conditions? If so, how would you do this.

Thanks,
Nicholas

------------------
Quote Reply
Re: A couple of questions In reply to
CEGlobe,

Quote:
#1 - How do you make reference to a filed in categories.db in site_html.pl?

A lot depends on where in site_html.pl you mean. In sub site_html_category, the fields are predefined for you (see the comments at the top of the routine). In sub site_html_print_cat, you can use the form "@{$category{$subcat}}[x]" where "x" is the field number as defined in category.def (the first field, ID, is "0").

Quote:
#2 - Is it possible to have for an if clause, two conditions? If so, how would you do this.

You can use many different forms:

Both something and something_else must be true (&& = logical and).
if ( (something) && (something_else) ) { do this; }
or
if ( (something) and (something_else) ) { do this; }

Either something or something_else must be true (| | = logical or). Note that this BBS is putting a blank space between the "| |" but it should not be there in your code.
if ( (something) | | (something_else) ) { do this; }
or
if ( (something) or (something_else) ) { do this; }

if (something)
{ do this; }
elsif (something else)
{ do that; }
else
{ do another_thing; }

The "else" part of the above statement is optional. Some folks use:

else { }

I hope this helps.

------------------
Bob Connors
bobsie@orphanage.com
www.orphanage.com/goodstuff/
goodstufflists.home.ml.org/


[This message has been edited by Bobsie (edited January 07, 1999).]
Quote Reply
Re: A couple of questions In reply to
Thanks Bobsie. With the category fields thing, I was talking about if I added my own new fields to it, how would I reference those. For example, if I added a "graphic" field to the categories.db, how would I reference this in site_html_category?

Thanks,
Nicholas

------------------
Quote Reply
Re: A couple of questions In reply to
Nicholas,

Go to sub build_category_pages in nph-build.cgi. Add your graphic variable (i.e., $graphic) to the local variables list (or add a new local variable list with $graphic in it).

In that routine, you will see:

Quote:
# We set up all the variables people can use in &site_html.pl.
($description, $related, $meta_name, $meta_keywords, $header, $footer) = @{$category{$cat}}[2..7];

Assuming your "graphic" field was added to the end of your fields defined in category.def, just change the above to read:

Quote:
# We set up all the variables people can use in &site_html.pl.
($description, $related, $meta_name, $meta_keywords, $header, $footer, $graphic) = @{$category{$cat}}[2..8];

You will then be able to reference that field in sub site_html_category using the $graphic variable.

I hope this helps.

------------------
Bob Connors
bobsie@orphanage.com
www.orphanage.com/goodstuff/
goodstufflists.home.ml.org/




[This message has been edited by Bobsie (edited January 08, 1999).]
Quote Reply
Re: A couple of questions In reply to
Thanks Bobsie

------------------