Reputation: 1559
I tried to display article image and description in another module in joomla. It like wordpress posts.
Here i want to display product name,Image and the description. So i took the title as the product name and now i want to divide introtext into two parts as image and description which article have.
I have post for every products which category id = 9.
This is the Code i used
<?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>
Can anyone help me to solve this problem?
Upvotes: 3
Views: 1303
Reputation: 8178
Have a look at components\com_content\views\article\tmpl\default.php
near the top you'll see this line of code to set $images
.
$images = json_decode($this->item->images);
Further down, you'll see how the image is displayed:
<?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; ?>
For description:
$title = $article->introtext; and/or $title = $article->fulltext;
Now, with that information, you need to create a template override so that you don't hack the core installation files. See How to override the output from the Joomla! core for details, but essentially, you do this using your template (I'll use beez3 for the example):
\templates\beez3\html\com_content\article
\components\com_content\views\article\tmpl\default.php
Upvotes: 3