Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何获得joomla文章的简介图像_Php_Joomla_Joomla3.0_Joomla Extensions - Fatal编程技术网

Php 如何获得joomla文章的简介图像

Php 如何获得joomla文章的简介图像,php,joomla,joomla3.0,joomla-extensions,Php,Joomla,Joomla3.0,Joomla Extensions,我正在尝试自定义我网站的类别列表。所以我有一个菜单选项,显示所有文章的列表是一个特定的类别。 在这个列表中,我想把文章的图片也显示出来。但不幸的是,我找不到每篇文章的介绍图像的路径,无法将其放入“”标记中 这段代码采用本文中的第一幅图像。这不是我想要的 <?php $text = $article->introtext; if(preg_match('/<\s*img[^>]+>/Ui', $text, $matches)){ $image=$matches

我正在尝试自定义我网站的类别列表。所以我有一个菜单选项,显示所有文章的列表是一个特定的类别。 在这个列表中,我想把文章的图片也显示出来。但不幸的是,我找不到每篇文章的介绍图像的路径,无法将其放入“”标记中

这段代码采用本文中的第一幅图像。这不是我想要的

<?php
$text = $article->introtext;
if(preg_match('/<\s*img[^>]+>/Ui', $text, $matches)){

   $image=$matches[0];
   $text = str_replace($image,'',$text);
}
if ($matches) {
$image = str_replace('img src="','img width="150px" src="/demo/persianlondon/',$image);
$image = str_replace("caption","", $image);
echo '' . $image . '';
}
else {echo '<img width="150px" src="http://goo.gl/k47rNN" class="defaultArticleImage" />';}
?>

因此,我需要获取简介图像url,并将其设置为
$image

有什么想法吗?

如果您正在谈论某个类别的博客视图,如果您将其放入文件中,此代码将写出带有路径的简介图像文件名:

jroot/component/com_content/views/category/tmpl/blog.php或在模板覆盖的blog.php文件中

$article_items = $this->get('lead_items');
foreach ($article_items as $item) {
  $imageObj = json_decode($item->images);
  echo $imageObj->image_intro;
}
$imageObj的其他变量:

stdClass Object
 (
   [image_intro] => 
   [float_intro] => 
   [image_intro_alt] => 
   [image_intro_caption] => 
   [image_fulltext] => 
   [float_fulltext] => 
   [image_fulltext_alt] => 
   [image_fulltext_caption] => 
 )

对于@GDP来说,这是个好问题。我不知道Joomla有一个StackExchange。然而,似乎没有人在那里。所有SE站点都由它们在世界各地的成员维护……最终会有人问你问题。:)介绍图像不在文章文本中,而是在图像字段中。您只需使用与在文章中显示相同的代码,其中包括对图像数据进行json_解码。我相信可能已经有一个jlayout为您管理了很多这方面的内容,但是只需查看category blog的代码并修改其中的内容即可。