Gossamer Forum
Home : Products : Gossamer Links : Discussions :

/ to > in Related Category display

Quote Reply
/ to > in Related Category display
I'm trying to format the related category display.
I'm not using the yahoo @ feature.
I want to change the display of related categories.
Currently they look like this as a link;

Lighting/Rental/Services

I want to change them to look like this;

Lighting > Rental > Services

I found the following link, but couldn't find the relevant code updated for LinksSQL 2.1.1:

http://www.gossamer-threads.com/...i?post=115029#115029

Any help would be most appreciated.
Quote Reply
Re: [Piers1] / to > in Related Category display In reply to
Can you show me an example of where the related category builds as "Lighting/Rental/Services"? There are a number of places that could be the location to change.
Quote Reply
Re: [Aki] / to > in Related Category display In reply to
Thanks for helping out Aki,

I'm currently developing the new site offline on my home server. This happens on any of the category pages, where I've got the following;

A subcategory listing, a list of links and finally any related categories.

The related categories print out in the format described. I've attached a sample page.

I've managed to change the category link display from / to > (in Build.pm), but can't seem to find a way to do this for the related categories.

Having spent hours trying to see how the related categories are build (very much guess work as my perl skills are almost non existent!), I need help!
Quote Reply
Re: [Piers1] / to > in Related Category display In reply to
I have a solution for you, but the solution depends on wheter you are using the <%related%> tag, or <%loop related_loop%>.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] / to > in Related Category display In reply to
I'm currently using the <%related%> tag in the category.html template.
I'm happy to use another tag at this stage if it helps.
Quote Reply
Re: [Piers1] / to > in Related Category display In reply to
I personally prefer the loop tag, because it gives you more flexibility, and I have just realized, it would be much easier to use here (I have also just realized that there is a bug in related_loop, the URL to the category is not provided....)
Code:
<ul>
<%loop related_loop%>
<%get_url_and_nice_name($Full_Name)%>
<li><a href="<%url%>"><%nice_name%></a></li>
<%endloop%>
</ul>
where the global get_url_and_nice_name($Full_Name) is defined as
Code:
sub {
my $fn = shift;
my $url = $DB->table('Category')->as_url($fn);
(my $nice_name = $fn) =~ s,/, &gt; ,g;
return { url => $url, nice_name => $nice_name };
}

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] / to > in Related Category display In reply to
Thanks Yoji,

Silly novice question, but where does this code go. I'm assuming the first snippet goes into my category.html template, and the second anywhere in Build.pm?
Quote Reply
Re: [Piers1] / to > in Related Category display In reply to
The second thing is a global variable, which you can define in "Build -> Template Globals", and the first goes in category.html, as you said.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] / to > in Related Category display In reply to
Yogi, you are a star, this works as I want it....thanks very much.
Quote Reply
Re: [Piers1] / to > in Related Category display In reply to
Huge delay in spotting this but......

I've added the global put the correct url isn't being printed. It seems to prefix the url with the category you are in.

You can see my problem by clicking on any of the related categories on this test site;

http://www.stagelink.com/Lighting/index.html

I'd modified the global to be called "related_cat_mod" to help me remember what it does!

Code:
sub {
my $fn = shift;
my $url = $DB->table('Category')->as_url($fn);
(my $related_categories_list = $fn) =~ s,/, &gt; ,g;
return { url => $url, related_categories_list => $related_categories_list };
}


I've then put the following into my category template;

Code:
<%if related%>
<font size="-1" color="#6f6f6f">&nbsp;<%category_short%> Related Categories</font>
<br>
<%loop related_loop%>
<%related_cat_mod($Full_Name)%>
&nbsp;&nbsp;<a href="<%url%>"><%related_categories_list%></a><br><%endloop%><br>
<%endif%>


Any ideas? During this time, I've added the Pagebuilder plugin. Would that effect the way the related URL is built?

At a loss right now.
Quote Reply
Re: [Piers1] / to > in Related Category display In reply to
Anyone?
Quote Reply
Re: [Piers1] / to > in Related Category display In reply to
Well due to the overwhelming response Wink, I've done a completely clean install of Links SQL and without adding plugin's or doing any changes I still get this URL path problem.

This should be such a simple thing to change yet I can't figure it out.

Is there another way around this?

Piers
Quote Reply
Re: [Piers1] / to > in Related Category display In reply to
The problem seems to be that the url that is returned is a relative url, and not an absolute one.

Try this
Code:
sub {
my $fn = shift;
my $url = $CFG->{build_root_url} . $DB->table('Category')->as_url($fn) . '/' . $CFG->{build_index};
(my $related_categories_list = $fn) =~ s,/, &gt; ,g;
return { url => $url, related_categories_list => $related_categories_list };
}

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] / to > in Related Category display In reply to
Almost!!!

I now get a url which misses out a / and doesn't capitalise the first category;

I get this as a url:

http://www.stagelink.comrigging/...ng_Rental/index.html

Rather then the correct one which would be;

http://www.stagelink.com/...ng_Rental/index.html

I feel like you're getting closer....
Quote Reply
Re: [Piers1] / to > in Related Category display In reply to
Oops. The my $url line should be:

my $url = "$CFG->{build_root_url}/" . $DB->table('Category')->as_url($fn) . "/$CFG->{build_index}";

I don't know about the missing capitalisation....

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] / to > in Related Category display In reply to
Yes this works and cures the capitals thing. Thanks for all your help.

For anyone reading this in the future here is all of the code in one post (works for LinksSQL 2.1.1);

In your category.html add the following where you want to replace the related category information (change the html to suit your site);

Code:


<%if related%>
<%loop related_loop%>
<%related_cat_mod($Full_Name)%>
<a href="<%url%>"><%related_categories_list%></a><br>
<%endloop%>
<%endif%>


Add a Template Global called: related_cat_mod

Code:


sub {
my $fn = shift;
my $url = "$CFG->{build_root_url}/" . $DB->table('Category')->as_url($fn) . "/$CFG->{build_index}";
(my $related_categories_list = $fn) =~ s,/, &gt; ,g;
return { url => $url, related_categories_list => $related_categories_list };
}