Gossamer Forum
Skip to Content



Quote Reply
Hide affiliate links
Hello,

I would like to add some affiliate links to my site.
Most affiliate links tend to have a long URL which doesn’t look that good.

I’m looking for a way to "shorten" the URL displayed in link.html

Example:
http://affiliatesite.com/sites.php?id=re_ps_dave5_A_2_A&site=dsd&tmpl=11

To:
http://affiliatesite.com/sites.php?…

I think the best way is to setup a limit to the number of characters displayed. Like 20 characters after the "http://" . All characters after will be replaced by ”…”

Any others ideas would be appreciated.

Thank you,
Dave Smile

Quote Reply
Re: [Kool] Hide affiliate links In reply to
Hi,

The easiest way, would be to "split" it at the ?, so anything after that doesn't get shown. Here's how you could do it:

trim_url_down

Code:
sub {
my $url = $_[0];
my @tmp = split /\?/, $url;
return $tmp[0];
}

Then just call with <%trim_url_down($URL)%>

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.com

Merry Xmas and a Happy New Year!


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!
Custom Toolbar for IE and Firefox! - Compare our different Plugin packages *new*
Free CSS Templates
Quote Reply
Re: [Kool] Hide affiliate links In reply to
Hi Kool:

I actually would recommend you don't use the url at all, but instead jump.cgi. There is no value in showing the url, and if you are actually aiming at trying to earn some income from affiliate sales etc, research has shown that many people will either not click on the link OR they will modify it.

Regards,


Clint
--------------------------
http://AffiliatesDirectory.com
The Affiliate Programs Directory
Quote Reply
Re: [Clint] Hide affiliate links In reply to
Hi,

I think he's trying to just show a URL, rather that the full link :)

i.e:

Title
Description
http://www.domain.com

..or similar :)

Cheers

Andy (mod)
andy@ultranerds.com

Merry Xmas and a Happy New Year!


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!
Custom Toolbar for IE and Firefox! - Compare our different Plugin packages *new*
Free CSS Templates
Quote Reply
Re: [Andy] Hide affiliate links In reply to
Thank you very much for the help guys!



I’m aware that some people will not click on URL/affiliate link.

Removing the URL completely is an option, but I’m not sure if showing a partial domain would be better.



Andy, if I want to show only the domain, what would be the code (including the .com. .net etc)? replace"?" with "/"



Split at the "?" will not work for all affiliate links. Some don’t have it.

where do I place the code <%trim_url_down($URL)%>

Thanks,

dave



Last edited by:

Kool: Sep 12, 2007, 10:41 AM
Quote Reply
Re: [Kool] Hide affiliate links In reply to
Hi,

You would just do:

Code:
sub {
my $url = $_[0];
my @tmp = split /\//, $url;
return $tmp[2];
}

Also, that will split the http:// bit up (thus why I changed it to $tmp[2], instead of $tmp[0]). If you want to use the http:// bit in the front, you would just need to change:

Code:
return $tmp[2];

..to:

Code:
return qq|http://| . $tmp[2];

Hope that helps.

BTW, please try not to use bold in your whole post, it makes them a bit sore on the eyes :(

Cheers

Andy (mod)
andy@ultranerds.com

Merry Xmas and a Happy New Year!


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!
Custom Toolbar for IE and Firefox! - Compare our different Plugin packages *new*
Free CSS Templates
Quote Reply
Re: [Andy] Hide affiliate links In reply to
Thank you Andy! I'll try it.
Quote Reply
Re: [Kool] Hide affiliate links In reply to
Do you need to display the link URLs at all?
Quote Reply
Re: [Alba] Hide affiliate links In reply to
Alba, do you suggest not showing the URL?

My intention is to trim the URL after the .com
Quote Reply
Re: [Kool] Hide affiliate links In reply to
Quote:
do you suggest not showing the URL?

Just a thought, I removed the code from my templates.