Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

limit the number of character in the url

Quote Reply
limit the number of character in the url
In the new gossamer link it possible to build name to the page like the mane of the title and it possible to make the page name url short then the title.
I use global to make the url like the title name, is it possible to make change the global code so the mane of the title will limit to number of character?

Here is the code I use (from yogi )

sub {
my $ID = shift;
my $Title = shift;
my $cats = $DB->table('Links')->get_categories($ID);
my ($cat_id,$cat_full_name) = each %$cats;
my $cat_url = $DB->table('Category')->as_url($cat_full_name);
$Title =~ y/ \t\r\n?"'#/--/d;
return '/' . $cat_url . '/' . $Title . '_L' . $ID;
}

limit the number of character in the url
Quote Reply
Re: [nir] limit the number of character in the url In reply to
I guess my first question wasn't clear.
How can determine that the link of the page will take the first 15 letters from the title.
If the title is long (over 15 letters), the URL will be constructed up to the 15th letter.
Quote Reply
Re: [nir] limit the number of character in the url In reply to
use substr()

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] limit the number of character in the url In reply to
Thanks. Can you give me some more details? Where do I put it in the code I gave in the former messege?
Quote Reply
Re: [nir] limit the number of character in the url In reply to
Try this;

Code:
sub {
my $ID = shift;
my $Title = shift;
my $cats = $DB->table('Links')->get_categories($ID);
my ($cat_id,$cat_full_name) = each %$cats;
my $cat_url = $DB->table('Category')->as_url($cat_full_name);
$Title =~ y/ \t\r\n?"'#/--/d;
unless (length $Title <= 15) { $Title = substr ($Title, 0, 15);}
return '/' . $cat_url . '/' . $Title . '_L' . $ID;
}

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] limit the number of character in the url In reply to
Thanks AndySmile
it do the work!

Quote Reply
Re: [Andy] limit the number of character in the url In reply to
Hi Andy,

Instead of limiting Title by no.of characters how can we limit it by no.of words.

Ex: mydomain.com/gossamer-links-widgets-L123.html

Instead of this mydomain.com/gossamer-links-wid-L123.html

Because I don't want some of the words to be cut-off

Appreciate your help

Thanks.