phpjoomlajoomla3.1

Get articles intro-image in Module


I'm new to Joomla and in the progress of developing a little module, that should display the intro-image of the article that is shown by the "com_article" component. The module should be a widget in a kind of sidebar, that's what it is for. I already searched the web and played around with JSite, but didn't get the data i was looking for.

How do i get the images uri?

Kind regards,

André


Solution

  • I finally found the answer:

    $articleId = JFactory::getApplication()->getRouter()->getVar("id");
    
    $db = JFactory::getDbo();
    
    $query = $db->getQuery(true)
            ->select($db->quoteName('images'))
            ->from($db->quoteName('#__content'))
            ->where('id = '. $db->Quote($articleId));
    
    $db->setQuery($query);
    $result = $db->loadResult();
    $images = json_decode($result);