[mod]Getting Rid of Full Path in "Link Details" URL - eSyndiCat User Forums
eSyndiCat User Forums esyndicat directory software esyndicat support

Go Back   eSyndiCat User Forums > eSyndiCat Directory Software [FREE] > Modifications

Modifications Simple to complex modifications, made by users or by our team, applied to logic or presentation, all kinds of modifications are discussed and requested here.

Reply
 
Thread Tools Display Modes
Old 09-07-2006   #1
Vincent Wright
 
Join Date: Sep 2005
Posts: 1,421
Vincent Wright is an unknown quantity at this point
Default [mod]Getting Rid of Full Path in "Link Details" URL

Greetings all,

today I have been searching through forums looking for old unanswered posts. And I found several request to implement a mod like stated in subject.

Note: this mod is only useful if you have mod_rewrite turned ON.

Let me explain what the mod is and how to implement it.

Imagine you have a directory in www.mydomain.com/dir/ with two (just an example) top level categories with one subcategory in each main category, like this:

Cat_1 \ Subcat_1

Cat_2 \ Subcat_2

Also, let's assume that there is one link in Subcat_1 titled "Test Link" [ID=1].

As you know each listing has a "Link Details" link that leads to a page with detailed link information. Typically, the URL of this link looks like this:

http://www.mydomain.com/dir/Cat_1/Subcat_1/test-link-l1.html

Now imagine, that you move this link from Cat_1/Subcat_1/ to Cat_2/Subcat_2/

In this case the "Link Details" URL will look like this:

http://www.mydomain.com/dir/Cat_2/Subcat_2/test-link-l1.html

Finally, imagine that by the time you move the link Google has indexed your pages and assigned some PageRank to this link's details page.

After you move the link, the previous Link Details page is now invalid.

The result: You loose PageRank.

In order for the links to be consistent no matter how you move them between categories it would be good to have Link Details URLs like this:

http://www.mydomain.com/link-detail-ID.html

where ID is the ID of the link, which in our case will look like

http://www.mydomain.com/link-detail-1.html

Ok, I think this info is enough to get the point of the mod.

Let get down to the mod itself...

1. Modify link-display.tpl

Open link-display.tpl (I use GreenLeaves), find this piece:

Code:
    {if $config.mod_rewrite}
        <a href="{$config.base}{$config.dir}{$link.path}/{convert_str string=$link.title}-{$link.id}.html">{$lang.link_details}</a>
    {else}
        <a href="{$config.base}{$config.dir}view-link.php?id={$link.id}">{$lang.link_details}</a>
    {/if}
and replace it with this one

Code:
    {if $config.mod_rewrite}
        <a href="{$config.base}{$config.dir}link-details-{$link.id}.html">{$lang.link_details}</a>
    {else}
        <a href="{$config.base}{$config.dir}view-link.php?id={$link.id}">{$lang.link_details}</a>
    {/if}
Save changes and close the file.

This will change the URL of Link Details link. You can check it by refreshing any listing page and hovering your mouse over any "Link Details" link.

But this change alone is not enough. Now we have to redirect link-details-ID.html to PHP file.

This is done with .htaccess

Open .htaccess file, find this rule:

Code:
# mod_rewrite rules for view link page
RewriteRule ^(.*)/(.*)-([0-9]+).html$ view-link.php?cat=$1&title=$2&id=$3 [QSA,L]
and replace it with this:

Code:
# mod_rewrite rules for view link page
RewriteRule ^link-details-([0-9]+).html$ view-link.php?id=$1 [QSA,L]
Save changes and close the file.

Now we have to tweak view-link.php slightly to correctly display category title/path.

Open view-link.php, find this snippet:

PHP Code:
/** get parent category info **/
$category $gDirConfig['mod_rewrite'] ? $gDirDb->getCategoryByPath($_GET['cat']) : $gDirDb->getCategoryById($link['id_category']);
$gDirSmarty->assign_by_ref('category'$category); 
and replace it with this one:

PHP Code:
/** get parent category info **/
$category $gDirDb->getCategoryById($link['id_category']);
$gDirSmarty->assign_by_ref('category'$category); 
Save changes and close the file.

That's it there is to it.

Play with it and see what happens.

Last edited by Vincent Wright; 09-07-2006 at 06:36 PM.
Vincent Wright is offline   Reply With Quote
Old 09-07-2006   #2
Samhan
'--------.
 
Join Date: Jul 2006
Posts: 67
Samhan is on a distinguished road
Send a message via ICQ to Samhan Send a message via MSN to Samhan
Default

Vincent,

It's good idea, thank you..

but,
there is a small mistake in step 2 [.htaccess] file..
[QSA,L] <-- the mistake in line #2!

find:
Code:
# mod_rewrite rules for view link page
RewriteRule ^(.*)/(.*)-([0-9]+).html$ view-link.php?cat=$1&title=$2&id=$3 [QSA,L]
change it to:
Code:
# mod_rewrite rules for view link page
RewriteRule ^link-details-([0-9]+).html$ view-link.php?id=$1 [QSA,L]
__________________
DirMaster.com
LinKaT.Tv
Samhan is offline   Reply With Quote
Old 09-07-2006   #3
Vincent Wright
 
Join Date: Sep 2005
Posts: 1,421
Vincent Wright is an unknown quantity at this point
Default

Ah, yes.

Thanks Samhan.

I have edited the post.
Vincent Wright is offline   Reply With Quote
Old 09-07-2006   #4
subseo
 
Join Date: Dec 2005
Posts: 436
subseo is an unknown quantity at this point
Default

That's way too cool. Thanks a lot, I almost forgotten and given up on this, that was my dream ever since I started with eSyndicat.
__________________
regards,Tom
subseo is offline   Reply With Quote
Old 09-08-2006   #5
Vincent Wright
 
Join Date: Sep 2005
Posts: 1,421
Vincent Wright is an unknown quantity at this point
Default

I'm glad this mod turns out to be useful
Vincent Wright is offline   Reply With Quote
Old 09-08-2006   #6
lsb
 
Join Date: Nov 2005
Location: Switzerland
Posts: 306
lsb has disabled reputation
Default

Quote:
Originally Posted by Vincent Wright
I'm glad this mod turns out to be useful
Hi Vincent!

Indeed! Very useful!

But I guess there is a small problem with it:
When you click on a crosslink, e.g.:
http...
then take:
@ Wie werden Evaluationsprojekte erfolgreich?
Link detail changes its category location to the original one.
In my case I clicked the crosslink here:
buecher/methoden/allgemein-kurz
but link details are shown here:
_Qualifikationsarbeiten/Dissertationen/
(not visible at the URL, but at the navigation bar just above the link details).
I guess visitors do not recognize this difference (they even do not know that @ means crosslinks), but are confused because they are in a different category then with different links and different topics. Of course they can click the browse-back-button, but if confusion could be avoided it would be better I think.
The behaviour before your mod was different: Link details where located in the category a visitor came from, and I guess such a behaviour would be more logical, or what do you think?

Greetings,
Lars

Last edited by lsb; 05-12-2007 at 11:12 PM.
lsb is offline   Reply With Quote
Old 09-09-2006   #7
billybh
 
Join Date: Feb 2006
Posts: 80
billybh has disabled reputation
Default

Very nice mod! So glad that you guys doing this for the users.
billybh is offline   Reply With Quote
Old 09-09-2006   #8
Vincent Wright
 
Join Date: Sep 2005
Posts: 1,421
Vincent Wright is an unknown quantity at this point
Default

to lsb

First of all, this is how eSyndiCat works and has nothing to do with this mod.

And I believe this is how major directories (like DMOZ) work as well.

This is even how Linux and Windows work: when you click an alias (filesystem link) you get to where the link points.
Vincent Wright is offline   Reply With Quote
Old 09-09-2006   #9
lsb
 
Join Date: Nov 2005
Location: Switzerland
Posts: 306
lsb has disabled reputation
Default

Quote:
Originally Posted by Vincent Wright
to lsb

First of all, this is how eSyndiCat works and has nothing to do with this mod.

And I believe this is how major directories (like DMOZ) work as well.

This is even how Linux and Windows work: when you click an alias (filesystem link) you get to where the link points.
Hi Vincent,

to say it clearly: I love this mod, it is a cool feature!

I guess I possibly was not clear enough with my issue.
The behaviour of the script has changed after the mod:
Before the mod a click on details of a crosslink (and only in the case of crosslinks it is important) of course opened the details-page, but this detail page was always located within the category a user comes from. E.g. if a link fits to 5 categories simultanously (and that is what crosslinks are about I think) the detail-pages were located in 5 different categories (visible at the navigation line, in my example "Evaluation Portal: Bücher » Methoden » allgemein (kurz) » Buch betrachten" or "Evaluation Portal: Bücher » _Qualifikationsarbeiten » Dissertationen » Buch betrachten" etc. for the same link depending on the location where you come from.
After the mod the same detail-pages are "only" located at one place:At the place the link is originally located.
If one comes from category1-subcategory2 and then clicks on a detail page of a crosslink, he lands at category1-subcategory1 if the link originally is located there. And if he comes from category12-subcategory3-subcategory4 and clicks on the same link there, he also lands at category1-subcategory1 (see navigation-line). And this behaviour is new (just after the mod). But I guess the original behaviour is more logical for users.
Was I clear enough so it is possible to understand what I mean?
Greetings,
Lars

Last edited by lsb; 09-09-2006 at 09:40 AM.
lsb is offline   Reply With Quote
Old 09-09-2006   #10
Vincent Wright
 
Join Date: Sep 2005
Posts: 1,421
Vincent Wright is an unknown quantity at this point
Default

Ah, sorry, I was wrong then.

I think this is the case because by default path information is passed along with link id, that's why it is possible to display category breadcrumb. But after you apply the mod only link id is passed that's why the original path is displayed.
Vincent Wright is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 12:56 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Testimonials | Articles | Support | Documentation | Privacy Policy | License | Affiliates | Contact Us | SEO Resources