How to "urlify" www.somesite.com?

modul - June 17, 2008 - 19:41

I have needed to make part of my site outside the regular Drupal (5.7) framework. That part is fully integrated in the site, but it doesn't make use of the regular Drupal stuff. I can, however, make use of all Drupal functions.

In the texts I get from my own queries, there are url strings. In its own content types, Drupal automatically "urlifies" them, i.e. it automatically wraps "a href etc." around these strings. I would like to do that in my texts too, but I can't figure out how.

Question: Is there a Drupal function which I can call to automatically "urlify" these www-strings? Which function?

Check the l() and url()

cog.rusty - June 17, 2008 - 20:17

Check the l() and url() functions. Usually l($text, $path)

http://api.drupal.org/api/function/l/5
http://api.drupal.org/api/function/url/5

Thanks for the reply,

modul - June 17, 2008 - 21:11

Thanks for the reply, cog.rusty, but I'm not sure those l() and url() functions are what I am looking for.

This is a sample input text:
"You can find Google on http: // www. google. com. It's a mighty fine thing"

The result to be shown should be:
"You can find Google on < a href= "http: // www. google. com">http: // www. google. com< / a>. It's a mighty fine thing".

(I'm putting some erroneous spaces in the url, just to show what I mean)

So, I'm looking for a function which takes a text as its input, say $text, and which gives me back the same text, but with the appropriate < a href...> codes. I don't know which url's are in the text, so I suppose the function I'm looking for needs to do some text parsing. Is there such a thing???

check the code related to input filters

mulogic - June 17, 2008 - 21:41

The filters like full html or the one which aloows a set of html tags, does this by default.
you might want to the check the relevant code..

I was a bit confused because

cog.rusty - June 17, 2008 - 22:02

I was a bit confused because since Drupal 5 this happens automatically in Drupal with an URL filter enabled in the default input format. But I see that you want to do this outside Drupal.

This is the relevant function, I think.

http://api.drupal.org/api/function/_filter_url/5

Thanks mulogic and

modul - June 18, 2008 - 07:29

Thanks mulogic and cog.rusty, _filter_url has done the trick!! Thanks a ton!

 
 

Drupal is a registered trademark of Dries Buytaert.