Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Tag in all below category

Quote Reply
Tag in all below category
How can I do this:

I have more than 1000 categories that are about 5 level deep. Now how do I make a tag for parent category and serve the content for all the sub categories beneath that category.

Like place a tag for PHP category [@ www.needscripts.com] and that tag content will be used/served in all the categories below it.

Thanks for the help in advance.

Vishal
-------------------------------------------------------
Quote Reply
Re: [TRPN] Tag in all below category In reply to
  1. Add a new field to the category database called "MySpecialTag".
  2. Go through all the top level categories, and add in the variable that you want to pass around.
  3. Add this global onto the category.html thing.


my ($rec) = @_;
if ($rec->{catid}){$id = $rec->{catid}}
my $cat_db = $DB->table('Category');
$cat_db->select_options ('ORDER BY Name'); my $sth = $cat_db->select ( { 'ID' => $id }, ['Full_Name']);
my $base;

while (my ($fullname) = $sth->fetchrow_array) {
$base = $fullname;
my $loc = index($base, "/");
$loc++;
$base = substr($fullname, 0, $loc);
if ($loc == -1){$base = $fullname;}
}

$cat_db->select_options ('ORDER BY Name'); my $sth = $cat_db->select ( { 'Full_Name' => $base }, ['YOUR_SPECIAL_VARIABLE_NAME']);
while (my ($SPECIALVAR) = $sth->fetchrow_array) {
$return $SPECIALVAR;
}



This code is really ugly and needs cleaning but should work. It would be more efficient if you gave every child category the variable from the root category, but that would take more programming.