我正在开发一个新模块,它将在滑块上显示特色项目。
我已成功获取模块中的数据,但对于介绍图像存在问题。
我的查询在这里:
// 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()
函数?