Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Category Names on Detailed Pages

Quote Reply
Category Names on Detailed Pages
Heya,

I'm using static detailed pages. My category structure looks like this: Region/Country/State

When a user enters a link they obviously selects the category it belongs to. I'd like to use the region, country and state in the link listing as well without asking the person to enter it again a second time when providing the details for the link.

What are the tags (if any) that I could use to call the names of the different category levels?

If someone selects: North America/United States/Texas as a category, I'd like to parse this to be able to print on the detailed link page:

Region: North America
Country: United States
State: Texas

Any advice? As a matter of interest, has anyone done this the other way round? Have the user select the three categories on separate drop downs when he enters his link and automatically derive the correct category from that?

Safe swoops
Sangiro
http://www.dropzone.com/
Quote Reply
Re: Category Names on Detailed Pages In reply to
You would need a custom tag to do that. Something like:

Code:
sub {
my $tags = shift;
my $link_id = $tags->{ID};
my $link_db = $DB->table ('Links');
my ($cat_id, $cat_name) = each %{$link_db->get_categories ($link_id)};
my ($region, $country, $state) = split /\//, $cat_name;
my $output = qq~
Region: $region <BR>
Country: $country <BR>
State: $state <BR>
~;
return $output;
}
Save that into your template globals, and then add the tag where you want the output to be.

Hope that helps,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Category Names on Detailed Pages In reply to
Thanks Alex.

Works like a charm - I spilt it up into 3 separate subs to create 3 separate tags to call individually.

Safe swoops
Sangiro
http://www.dropzone.com/
Quote Reply
Re: Category Names on Detailed Pages In reply to
Alex,

One more question. All my categories do not fall through to the "state" level, in fact it's only the United States that has that additional sub-category. Most are simply Region/Country.

I would like to print a line with the information on a state only if that sub-category actually exists, but for the life of me cannot get it to work the way I want. here's what seems logic:
Code:
<%if state%>
<TR>
<TD>State:</TD>
<TD><%state%></TD>
</TR>
<%endif%>
Regardless of whether the state sub-category exists, this still prints the row with no value where <%state%> is called. I assume that means that the <%state%> tag is not empty even though it has no value...

I've also tried: <%if state eq ''%> and <%if country eq 'United States'%>.

What am I doing wrong here?

Safe swoops
Sangiro
http://www.dropzone.com/
Quote Reply
Re: Category Names on Detailed Pages In reply to
Code:
my $output = qq~
Region: $region <BR>
Country: $country <BR>
State: $state <BR>
~;
You'd need to expand it somewhat:

Code:
my $output = qq~
Region: $region <BR>
Country: $country
~;

($state) && ($output .= qq~ <BR>State: $state <BR> ~;
PUGDOGŪ
PUGDOGŪ Enterprises, Inc.
FAQ: http://pugdog.com/FAQ


Quote Reply
Re: Category Names on Detailed Pages In reply to
Newbie-Question: How do i extract only the name of the category for one link?

Quote Reply
Re: Category Names on Detailed Pages In reply to
It depends where you are trying to extract it.

Give an example of the use.

PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Plugins:http://LinkSQL.com/plugin
Quote Reply
Re: Category Names on Detailed Pages In reply to
Hi pudog,

i thought about adding simply the name of the category of an entry in the detailed page ... any hint how to do this?

Thanks

Quote Reply
Re: Category Names on Detailed Pages In reply to
check:

http://gossamer-threads.com/p/144260

It shows how to dump out a list of the tags that are available in any template.

Very useful.

If the tag you need isn't there, might have to make a short global variable,
but it should be.

PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Plugins:http://LinkSQL.com/plugin
Quote Reply
Re: Category Names on Detailed Pages In reply to
Thanks pudog - this thread i've found before but i do not have any idea how to create a global for the actual category-name for detailed pages ...

Quote Reply
Re: Category Names on Detailed Pages In reply to
The category name isn't available in your template? Most commonly used (or obvious) tags are available, even if not currently used by the default templates.

PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Plugins:http://LinkSQL.com/plugin