2

How to get article alias name by using article title in joomla? i want the alias name which one is stored in database.

saravankg
  • 909
  • 1
  • 10
  • 21
  • Do you mean you want to know how to create the alias or do you mean you want to retrieve it? The problem is that neither of these needs to be unique (although alias has to be unique within a category). – Elin Jul 24 '15 at 10:40

1 Answers1

1

You can try something like this:

        $title = 'Article title'; // Your article title

        $db = JFactory::getDbo();           

        $query = $db->getQuery(true);

        $query->select($db->quoteName('alias'))
                ->from($db->quoteName('#__content'))
                ->where($db->quoteName('title') . ' = ' . $db->quote($title));

        $db->setQuery($query);

        try 
        {
            $alias = $db->loadResult(); // variable has now article alias
        } 
        catch (Exception $ex) 
        {
            $alias = null;
        } 

        if ($alias)
        {
            // Do something with alias
        }
arbogastes
  • 1,308
  • 9
  • 10