2
我正在開發一個新的模塊,它將顯示滑塊上的特色項目。如何從Joomla的db中獲取文章的圖像路徑
我已成功獲取我的模塊中的數據,但對於介紹圖像有問題。
我的查詢是在這裏:
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query
->select(array('f.content_id', 'c.id', 'c.title', 'c.alias', 'c.images'))
->from('#__content AS c')
->join('INNER', '#__content_frontpage AS f ON (c.id = f.content_id)')
->where("c.language = '" . JFactory::getLanguage()->getTag() . "' AND c.state=1")
->order('f.ordering ASC');
// Reset the query using our newly populated query object.
$db->setQuery($query);
// Load the results as a list of stdClass objects.
$results = $db->loadObjectList();
foreach ($results as $r)
{
$imagePath = $r->images;
//.
//.
//.
}
正如你所知道的圖像路徑保存在images
列在目錄類似以下形式:
{
"image_intro":"images\/products\/201191420496.jpg",
"float_intro":"",
"image_intro_alt":"",
"image_intro_caption":"",
"image_fulltext":"",
"float_fulltext":"",
"image_fulltext_alt":"",
"image_fulltext_caption":""
}
我想知道如何提取的介紹圖像路徑從這個數據。有沒有一個共同的功能/方法呢,還是應該使用PHP的explode()
函數?