Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Inserting category name in category.html

Quote Reply
Inserting category name in category.html
I know the solution is simple but i coulc not figure it out.
I am trying to insert the category name within the category.html to be replaced in each category by the name. I have tried the following tags:
<%category_name%>
<%category_title%>
<%category_clean%>
<%title%>
and they are all returning Top_category/Sub_category while I only want the subcategory name to appear.

Any suggestions?

Regards
Abd

http://www.idleb.com
Quote Reply
Re: Inserting category name in category.html In reply to
The easiest way, but not the most portable, would be to simply insert a line into Links/Build.pm:

Code:
# Get our output vars.
$display{category_id} = $category->{'ID'};
$display{category_name} = $category->{'Full_Name'};
$display{category_Sname} = $category->{'Name'}; ## ADD THIS
$display{header} = $category->{'Header'};
$display{footer} = $category->{'Footer'};
$display{meta_name} = $category->{'Meta_Description'};
$display{meta_keywords} = $category->{'Meta_Keywords'};
$display{description} = $category->{'Description'};
$display{random} = int rand (10000);
$display{random1} = int rand (10000);
$display{random2} = int rand (10000);
$display{random3} = int rand (10000);
At that point, <% category_Sname %> would be a tag in your category templates.

Because of how the category tags have always been handled, alex really needs to make sure that all the fields are available when the table fields are re-assigned to the display fields. It would save a lot of confusion.

PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Forum:http://LinkSQL.com/forum
Quote Reply
Re: Inserting category name in category.html In reply to
Thanks a lot
Works great

Regards
Abd

http://www.idleb.com
Quote Reply
Re: Inserting category name in category.html In reply to
Hi,

Actually, right after that code is:

Code:
# Set any other attributes as well.
foreach my $key (keys %$category) {
exists $display{$key} or ($display{$key} = $category->{$key});
}
So you can use <%Name%> to display the name, or any other column name in the category table. I'd recommend switching this as it won't break when you upgrade.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Inserting category name in category.html In reply to
Hmm... I thought about that, but I missed that code section. There are still some problems with the code, that _could_ occur in some cases where a plug-in created a generic value for that

>> # Set any other attributes as well. foreach my $key (keys %$category)
>> { exists $display{$key} or ($display{$key} = $category->{$key}); }

It looks like that would overwrite the keys only if they don't exist, which means name clashes could occur, and the expected value wouldn't get printed out.

Maybe it's time for a full re-think of the templates and template variables -- as you mentioned with the loop-code stuff.

Maybe template variables should be of the sort -- cat_Name, Cat_ID, Link_ID, Link_Title, Link_Description, User_Name, User_Email, LinkOwner_Email, etc.

This would keep the variables separate, and prevent any sort of name clashing.



PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Forum:http://LinkSQL.com/forum