How to add image in joomla for each article sidebar

In this post i would like to explain about how to add image in joomla for each article sidebar. If we want to add some categories or articles images for sidebar of joomla website. Just cutomize the joomla code and implement it by simple code.

how to add image in joomla for each article sidebar | Anil Labs

how to add image in joomla for each article sidebar | Anil Labs

In the admin we have to place the below code in the file


Search for below code

echo $editor->display( 'text',  $row->text , '100%', '550', '75', '20' ) ;

After this we have add below code

    <tr valign="top">
            <td>Category Image</td>                            
            <td><input type="file" id="file-upload-entete" name="FileCategory" /></td>                             
            <td><img src='<?php echo JURI::base(); ?>../images/<?php echo $row->id; ?>/category.jpg' width=50 height=50 border=0></td>
            <td><input type="checkbox" name="delCategory"> </td>

We have upload the images at the file


Search for below code

$dispatcher->trigger('onAfterContentSave', array(&$row, $isNew));

After this line of code add in that page

if($_FILES['FileCategory']['tmp_name'] !=""){
         mkdir("../images/".$row->id); // Create folder for this article

In the front-end we have to get the image of particular article id and display it in the sidebar

Just open the file which is located at

templates\[YOUR TEMPLATE NAME]\html\com_content\article\default.php

Search for the below code

defined('_JEXEC') or die('Restricted access');

After this code add the below code:

$sEncartPath = $_SERVER["DOCUMENT_ROOT"] . "/images/" . $this->article->id . "/category.jpg";

In the sidebar we can write own syyles to display our category images… by below code

 if (file_exists($sEncartPath))
  <img src="images/<?php echo $this->article->id;?>/category.jpg" width="256" height="220">

Hope this will be useful.

Anil Kumar Panigrahi

With more than 10 years experience in PHP and Founder of Anil Labs, a blog for PHP and related posts. contributed posts regarding CodeIgniter, CakePHP and Learn PHP online ... Contact : [email protected]

You may also like...

3 Responses

  1. serge says:

    it is for 1.5 , isn’t it ?

  2. Simon says:

    Where i can find this file in Joomla 2.5??
    Please let me know i realy want this to work ..

  3. bibin says:

    Nice tutorial,, must know guide for joomla developers..

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.