Gossamer Forum
Home : Products : Links 2.0 : Customization :

link to the same category in another language

Quote Reply
link to the same category in another language
i have installed two 'links 2' scripts, one is french the other is english.

(http://... .net/fr/index.shtml) + (http://... .net/en/index.shtml)

they have the same category tree/structure.

then in a french category page, i wish to do a link to the same category page in english.

ex : in 'http://... .net/fr/mycategory/index.shtml'

i wish this link to be created automatically :

<a href="http://... .net/en/mycategory/index.shtml">Visit the english page</a>



Do you have an idea how to do ?

tanx Sly
Quote Reply
Re: [jigme] link to the same category in another language In reply to
I think this will do what you want... Add the red parts, and change the location and appearance of the link (second red part) as you like. From site_html_templates.pl:

# First let's get the name, number of links, and last modified date...
$url = "$build_root_url/" . &urlencode($subcat) . "/";
$en_url = "$build_root_url/en/" . &urlencode($subcat) . "/";
if ($subcat =~ m,.*/([^/]+)$,) { $category_name = &build_clean($1); } else { $category_name = &build_clean($subcat); }
$numlinks = $stats{"$subcat"}[0];
$mod = $stats{"$subcat"}[1];

# We check to see if we are half way through, if so we stop this table cell
# and begin a new one (this lets us have category names in two columns).
if ($i == $half) {
$output .= qq|</td><td class="catlist" valign="top">\n|;
}
$i++;

# Then we print out the name linked, new if it's new, and popular if its popular.
$output .= qq|<dl><dt><strong><a class="link" href="$url">$category_name</a></strong> <small class="numlinks">($numlinks)</small> |;
$output .= qq|<small><sup class="new">new</sup></small>| if (&days_old($mod) < $db_new_cutoff);
$output .= qq|</dt>|;
$output .= qq|<dd><span class="descript">$description </span></dd>| if (!($description =~ /^[\s\n]*$/));
$output .= qq|<a class="link" href="$en_url">Visit the english page.</a>|;
$output .= qq|</dl>|;
}


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] link to the same category in another language In reply to
tanx a lot for your help.Wink

actually the result is that the link 'visit the english page' is
'http://... .net/fr/en/my_category/index.shtml'
(and then it does not work, it should be 'http://... .net/en/my_category/index.shtml')

because the initial link is
'http://... .net/fr/my_category/index.shtml'.

also, the 'visit the english page' appears in the 'homepage' (and this, i don t need) but not in the category pages. i would have liked to include the 'visit the english page' as <%en_category%> in the templates in order to put it at the bottom of the category pages.

do you think i still can get it work ?

cheers.Smile
Quote Reply
Re: [jigme] link to the same category in another language In reply to
Change;

Code:
$en_url = "$build_root_url/en/" . &urlencode($subcat) . "/";

...to...

Code:
$en_url = "$build_root_url/en/" . &urlencode($subcat) . "/";
$en_url =~ s/fr\///;

Cheers


Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] link to the same category in another language In reply to
Or, instead of $build_root_url, just put the url in longhand: $en_url = "http://... .net/en/" . &urlencode($subcat) . "/";

Try this, in the category.html template, add the red:

<!-- Links in this category. -->
<%if links%>
<h2>Links: </h2>
<%links%>
<%endif%>
<%en_category%>

Then in db_utils.pl, add this:

##XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
## alt language link, called by <%en_category%>
sub en_category {
# --------------------------------------------------------
#
$en_category = &site_html_en_category;
return $en_category;
}
## end mod
##XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


Then, in site_html_templates.pl, add this:

sub site_html_en_category {
# --------------------------------------------------------
# This routine will build an alt language link.

return &load_template (en_category.html', {
%rec,
%globals
} );
}


At the top of this file, add your new sub to the list under %globals like so:
en_category => &en_category,

Finally, in the template directory, create a new file named en_category.html, and make the code how you want the link to appear:

<A HREF="http://... .net/en/$category">See this category in English.</A>

No guaranteesUnimpressed But this should be the right direction, anyway. Not that ther isn't an easier way, maybe, but I have similar things done on my site...


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: Sep 24, 2003, 12:35 AM
Quote Reply
Re: [Andy] link to the same category in another language In reply to
Yes ! Thank you, it works !!!Wink but it gives the english category link close to the french one in the categories list.

actually i wished only one english link to appear in the bottom of the page according to the french category page the visitor is in.
Quote Reply
Re: [PerlFlunkie] link to the same category in another language In reply to
thanks for your help.Cool

i replaced :
return &load_template (en_category.html', {
by :
return &load_template ('en_category.html', {

but actually the link appears exactly like that
<A HREF="http://... .net/en/$category">See this category in English.</A>

'$category' is not replaced by anything ... Pirate
then i tried with '$en_category' in 'en_category.html' too, unsuccessfully ... Unsure

Quote Reply
Re: [jigme] link to the same category in another language In reply to
My bad, yes it should be ( 'en_category.html', {

Try adding this to it; category => $category, like so:

sub site_html_en_category {
# --------------------------------------------------------
# This routine will build an alt language link.

return &load_template (en_category.html', {


Category => $category,
%rec,
%globals
} );
}

(Note capital 'C', then lowercase 'c')

Maybe this will work... for the link, use

<A HREF="http://... .net/en/($in{'Category'})">See this category in English.</A>


If not, it will end up being something similar.... we'll figure it out eventually!Tongue


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: Sep 24, 2003, 12:32 PM
Quote Reply
Re: [PerlFlunkie] link to the same category in another language In reply to
same result. the link appears like :
<A HREF="http://... .net/en/($in{'Category'})">See this category in English.</A>

with no value instead of : ($in{'Category'}) Pirate
Quote Reply
Re: [jigme] link to the same category in another language In reply to
OK, I guess the translation needs to come from somewhere besides the template. Change this, adding the red:

##XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
## alt language link, called by <%en_category%>
sub en_category {
# --------------------------------------------------------
#
$en_cat = ($in{'Category'})
$en_category = &site_html_en_category;
return $en_category;
}
## end mod
##XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


And then make the link like so:

<A HREF="http://... .net/en/<%en_cat%>">See this category in English.</A>


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] link to the same category in another language In reply to
thanks for your continuous help.Wink

well, i added a ; at the end of your code or links2 did not want to start at all :

$en_cat = ($in{'Category'}) ;
$en_category = &site_html_en_category;
return $en_category;


still, the result is : Unknown Tag: en_cat, instead of what should appear in place of <%en_cat%>.Pirate



If you have any further idea it is most welcome, however, thanks again for your kind help. If i don t give you fast answer from now on it will be because i must be offline for several weeks, but for sure i will give you answer if you have any new idea. Thanks again. Jigme.Smile
Quote Reply
Re: [jigme] link to the same category in another language In reply to
Well, at least it did something different!Tongue

Add the new name like you did the other, here:

Then, in site_html_templates.pl, add this:

sub site_html_en_category {
# --------------------------------------------------------
# This routine will build an alt language link.

return &load_template (en_category.html', {
%rec,
%globals
} );
}


At the top of this file, add your new sub to the list under %globals like so:
en_category => &en_category,

en_cat => &en_cat


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] link to the same category in another language In reply to
Well, i get this message 'Error including libraries: Undefined subroutine &main::en_cat'.
Ok i give up. Thank you very much for your kind efforts for helping.

cheers