Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Option: Shorter URLs for Links' directory pages

Quote Reply
Option: Shorter URLs for Links' directory pages
Many people recommend Links because of its flexibility, etc., and truly it seems to be a very useful software.

But the point that stops me from using it, is the length of Links' URLs.

Links is similar to Yahoo. A real example of URL:


Really, I would like shorter URLs, easier to quote in e-mails, papers, documents, publications, etc.

The previous example may be:


All this is just about an option to choose or change the URL of every new page of the directory (during the creation of a new category or section).

A new field in the creation form would be sufficient.

Of course, keeping the tree structure of categories, etc., but changing only the urls.

Thank you very much if someone knows a way to do this (if this option is possible with Links).

[This message has been edited by Juan G (edited April 16, 2000).]
Quote Reply
Re: Option: Shorter URLs for Links' directory pages In reply to
Looking at the Links scripts, I've found the following lines repeated in several of them:

# $url : The URL to go to that category
# $category_name : The category name with _ and / removed.
# (...)

my (@subcat) = @_;

# (...)

foreach $subcat (sort @subcat) {

# (...)

$url = "$build_root_url/" . &urlencode($subcat) . "/";
if ($subcat =~ m,.*/([^/]+)$,) { $category_name = &build_clean($1); } else { $category_name = &build_clean($subcat); }

I am thinking maybe a possible solution to implement the option to choose the URLs of the directory pages would be to add, after the line
$url = "$build_root_url/" . &urlencode($subcat) . "/";
in those scripts, something similar to the following:

if ($custom_url) { $url = $custom_url; }

getting $custom_url from a custom field in the add category form.

Sincerely, I know very very little Perl, so maybe this is not correct.

I would be truly grateful if others can explain a better solution. Thank you very much.
Quote Reply
Re: Option: Shorter URLs for Links' directory pages In reply to
Another point about this. In the Resources section we can read the following interesting page:

How to Add New Fields to Links 2.0

The writer says about links.def file, and now I've just seen this line in that file:

URL => [2, 'alpha', 40, 75, 1, 'http://', '^http|news|mailto|ftp'],

I don't know what is the best way to implement an optional field for customized URL in the add category form.

Quote Reply
Re: Option: Shorter URLs for Links' directory pages In reply to
Well, my mistake. Instead of links.def, it seems that we must use in this case the category.def file, where there is not a URL field.

Probably we can add a custom_url field, but I don't know if this can cause problems or not.