phpjoomlatagsjoomla3.1

How to get the tags associated to an article in Joomla


I need to get the TAGS associated with an article in Joomla 3.1.5

I have tried the following but they do not return a string:

echo $article->item->tags->itemTags;

and

$tags = $article->get("tags");

And just for the record I am loading the article info as such (getting the article title works perfectly)

$article = JTable::getInstance("content");
$article->load(JRequest::getInt("id"));
$pageTitle = $article->get("title");
$user =& JFactory::getUser();

Solution

  • If you look in components/com_content/views/article/tmpl/default.php, the tags are being displayed like so:

    if ($this->params->get('show_tags', 1) && !empty($this->item->tags->itemTags)) {
        $this->item->tagLayout = new JLayoutFile('joomla.content.tags');
        echo $this->item->tagLayout->render($this->item->tags->itemTags);
    }
    

    So you can base it on this:

    Hope it helps