Formatted links, howto?
Posted by: student101 (---.saix.net)
Date: January 27, 2008 08:34AM

How do you this on this forum?

If I add this link from Furkids it gets formatted to only display the domain name?

[furkids.co.za]

How to do that?



Edited 1 time(s). Last edit at 01/28/2008 02:46PM by student101.

Options: ReplyQuote
Re: Formatted links, howto?
Posted by: student101 (---.saix.net)
Date: January 28, 2008 02:48PM

I know you guys are busy and this isn't part of wamp but it is an interesting topic no?

Options: ReplyQuote
Re: Formatted links, howto?
Posted by: rip_pit (---.w82-125.abo.wanadoo.fr)
Date: January 29, 2008 05:23PM

i think it's a good mean not to flood the posts with ultra long links.
Just move your mouse over the "domain" and you'll see the full url in the browser statut bar.

---------------------------------------------
XP SP3 - pIV - 3.2Ghz - 1.5Go de ram - Wamp 2.0

Options: ReplyQuote
Re: Formatted links, howto?
Posted by: student101 (---.saix.net)
Date: January 30, 2008 07:33AM

Yes works well, but how to do it?

Do you need a special add-on or wordpress or is it PHP coding/programming?

Cheers

Options: ReplyQuote
Re: Formatted links, howto?
Posted by: yfastud (Moderator)
Date: January 30, 2008 02:53PM

If I'm not wrong, it's php codings which detect the first / and only output to the screen what ever in front of it, of course, the whole link still remain intact

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Re: Formatted links, howto?
Posted by: student101 (---.saix.net)
Date: January 30, 2008 03:11PM

Not sure how that works?

You mean if I add

[http://www.exampledomain.com/link?id=linkid&link2=linkid]
there is a PHP script that checks it and only displays
[www.exampledomain.com] or [exampledomain.com]

Isn't this called url something? (not sure what the actual name is)

It freakin' cool, would like to learn it.

Cheers

Options: ReplyQuote
Re: Formatted links, howto?
Posted by: rip_pit (---.w82-125.abo.wanadoo.fr)
Date: January 30, 2008 06:58PM

this is so called "url rewriting" but often used in apache's .htaccess files.
you're It's a kind of url rewriting ...

here's a script to help you :

/* original source @ [www.php.net] ** modified to feet the need. */

$anyurl = "[www.exampledomain.com];;
preg_match (  '@(http://.*[^/])([/].*)@i' , $anyurl , $matches  );
print_r($matches); // print all stored results
printf("<p><a href=\"%s\">[%s]</a></p>", $anyurl, $matches[1] ); // print simple link
printf("<p>[<a href='%1\$s' title='%1\$s'>%2\$s</a>]</p>", $anyurl, $matches[1]); //with title

/* Replace the preg_match line with this one to exclude capturing the http:// caracters :
preg_match('@(?:[])(.*[^/])([/].*)@i', $anyurl, $matches);*/

---------------------------------------------
XP SP3 - pIV - 3.2Ghz - 1.5Go de ram - Wamp 2.0



Edited 2 time(s). Last edit at 01/30/2008 07:08PM by rip_pit.

Options: ReplyQuote
Re: Formatted links, howto?
Posted by: student101 (---.saix.net)
Date: January 30, 2008 08:58PM

Looks helpful, will try it now.

Options: ReplyQuote
Re: Formatted links, howto?
Posted by: student101 (---.saix.net)
Date: January 30, 2008 09:04PM

Thank you

Works very well,
Where on earth did you get this script?

Options: ReplyQuote
Re: Formatted links, howto?
Posted by: student101 (---.saix.net)
Date: January 30, 2008 09:31PM

Made a small change to the script:


/* original source @ [www.php.net] ** modified to fit the need. */

$anyurl = "[www.exampledomain.com];; 
//or use above options to get the link/url

/* $anyurl = $_GET['geturl']; //get url
$anyurl =$_SESSION['geturl']; //post url
$anyurl = $_POST['geturl']; //session url */

preg_match ('@(http://.*[^/])([/].*)@i' , $anyurl , $matches);
print_r($matches); // print all stored results
printf("<p>[<a href=\"%s\">%s</a>]</p>", $anyurl, $matches[1] ); // print simple link
printf("<p>[<a href='%1\$s' title='%1\$s'>%2\$s</a>]</p>", $anyurl, $matches[1]); //print with title

/* Replace the preg_match line with this one to exclude capturing the http:// caracters :
preg_match('@(?:[])(.*[^/])([/].*)@i', $anyurl, $matches);*/

-----------------------
Thanks for your support!



Edited 3 time(s). Last edit at 03/08/2008 09:27AM by student101.

Options: ReplyQuote
Re: Formatted links, howto?
Posted by: rip_pit (---.w90-30.abo.wanadoo.fr)
Date: January 31, 2008 05:44PM

good.

There are a lot of Regular expressions like this over the net , use them to extract formatted strings from any other string. They can be used to validate email adress, ip, phone numbers, urls, and much more.

if u need to learn more :
[www.regular-expressions.info]

i get the regexp from this url :
[www.php.net]

---------------------------------------------
XP SP3 - pIV - 3.2Ghz - 1.5Go de ram - Wamp 2.0

Options: ReplyQuote


Sorry, only registered users may post in this forum.