Php 如何在模块joomla中分别显示描述和文章中的图像

Php 如何在模块joomla中分别显示描述和文章中的图像,php,joomla,Php,Joomla,我试图在joomla的另一个模块中显示文章图像和描述。它就像wordpress的帖子 这里我想显示产品名称、图像和描述。 所以我把标题作为产品名称,现在我想把介绍分为图片和文章描述两部分 我有每一个类别id=9的产品的帖子 这是我使用的代码 <?php catID = 9; //echo $catID; $doc = JFactory::getDocument(); $page_title = $doc->getTitle(); $db = JFactory::getDBO(); $

我试图在joomla的另一个模块中显示文章图像和描述。它就像wordpress的帖子

这里我想显示产品名称、图像和描述。 所以我把标题作为产品名称,现在我想把介绍分为图片和文章描述两部分

我有每一个类别id=9的产品的帖子

这是我使用的代码

<?php
catID = 9;
//echo $catID;
$doc = JFactory::getDocument();
$page_title = $doc->getTitle();
$db = JFactory::getDBO();
$db->setQuery("SELECT title, introtext FROM #__content WHERE catid = ".$catID);
$articles = $db->loadObjectList(); ?> 

<div class="row">
<div class="col-md-12">
    <div class="col-md-4">
    <div class="nopadding">
    <?php foreach($articles as $article){
$title = $article->title;?>
<!-- Image -->
<!-- Description -->
        <img class="ras-img" src=""><!-- Image should add here -->
        <div class="ras-hvr">
            <div class="ras-inner-hvr">
            <div class="row">
                    <div class="col-md-6  pro-name"><?php echo $article->title; ?></div>
            </div>
            <div class="row">
                    <div class="col-md-12  pro-des"><!-- Description here --></div>
            </div>
        </div>
        </div>
        <?php } ?>
    </div>
    </div>
    </div>
</div>


有人能帮我解决这个问题吗?

看看
组件\com\u内容\views\article\tmpl\default.php
在顶部附近,您将看到这行代码,用于设置
$images

$images  = json_decode($this->item->images);
再往下看,您将看到图像的显示方式:

<?php if (isset($images->image_fulltext) && !empty($images->image_fulltext)) : ?>
<?php $imgfloat = (empty($images->float_fulltext)) ? $params->get('float_fulltext') : $images->float_fulltext; ?>
<div class="pull-<?php echo htmlspecialchars($imgfloat); ?> item-image"> <img
<?php if ($images->image_fulltext_caption):
    echo 'class="caption"'.' title="' .htmlspecialchars($images->image_fulltext_caption) . '"';
endif; ?>
src="<?php echo htmlspecialchars($images->image_fulltext); ?>" alt="<?php echo htmlspecialchars($images->image_fulltext_alt); ?>"/> </div>
<?php endif; ?>
现在,有了这些信息,您需要创建一个模板覆盖,这样您就不会侵入核心安装文件。有关详细信息,请参见,但本质上,您可以使用模板(我将使用beez3作为示例):

  • 创建文件夹
    \templates\beez3\html\com\u content\article
  • 在该文件夹中,复制
    \components\com\u content\views\article\tmpl\default.php
  • 对复制的php文件进行布局更改
  • Joomla将查找它并从那里加载它(如果它存在),而不是核心文件

  • 你能补充更多关于这个问题的信息吗?关于文章图片,请查看我之前的帖子:。首先,你绝对不应该在文章布局中进行查询。如果没有其他内容,请使用插件获取数据。当你说“模块”时,你是指Joomla模块还是指组件?只要在你和它的任何地方回显你的图像数据,就像在文章的核心布局或文章介绍中一样(就像在博客布局中一样)。还可以使用Joomla api进行查询。现在还不清楚您在做什么,也不清楚为什么它需要的不仅仅是布局覆盖。
    $title = $article->introtext;   and/or   $title = $article->fulltext;