Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Joomla function to generate the 'alias' field?

I'm writing my own component for Joomla 1.5. I'm trying to figure out how to generate an "alias" (friendly URL slug) for the content I add. In other words, if the title is "The article title", Joomla would use the-article-title by default (you can edit it if you like).

Is there a built-in Joomla function that will do this for me?

like image 651
DisgruntledGoat Avatar asked Nov 12 '09 17:11

DisgruntledGoat


2 Answers

If you are trying to generate an alias for your created component it is very simple. Suppose you have click on save or apply button in your created component or suppose you want to make alias through your tile, then use this function:

$ailias=JFilterOutput::stringURLSafe($_POST['title']);

Now you can insert it into database.

like image 122
nanhe Avatar answered Oct 05 '22 06:10

nanhe


Line 123 of libraries/joomla/database/table/content.php implements JFilterOutput::stringURLSafe(). Pass in the string you want to make "alias friendly" and it will return what you need.

like image 27
jlleblanc Avatar answered Oct 05 '22 07:10

jlleblanc