A simple and useful workaround to show images in the category list for each document.
We need to change 2 joomla files :
- article.xml
- default_items.php
article.xml
Download the article.xml from
Joomla_path/administrator/components/com_content/models/article.xml
This file xml describes the list of fields available in Administration-Manage Article like "Advanced" section.
Before to procede make a backup copy of article.xlm.
So, edit the file (I usual use notedpad++) because we will add a new line.
Search for
<params group="advanced">
and after insert this row :
<param name="image" type="text" default="" label="Image URL" description="" />
Save and upload it in :
Joomla_path/administrator/components/com_content/models
OK, now we need to test if we see the new field in Joomla Administrator...
Make a new article and on Advanced options , if all it's ok, you will find the new field “Image URL”.
The Image URL will be saved in the attribs field of jos_content table.
default_items.php
PATH_TO_JOOMLA/administrator/components/com_content/controller.php
Download and make a backup copy of default_items.php
Note : we will upload the file in another path :
PATH_TO_JOOMLA/templates/Your_Template/html/com_content/category
EDIT the file and add at the end of file the following function :
<REMOVE_ME?php
function myimage($attribs) {
$myarray=explode("\n", $attribs);
foreach($myarray as $key => $val) {
if (substr($val,0,6)=="image=") {
return substr($val,6);
}
}
return "";
}
?REMOVE_ME>
Now, go to near the line 69, search for the following instruction and remark it :
// echo $this->pagination->getRowOffset( $item->count );
then add the following instruction after the above line remarked:
// Image
$tmpattribs=$item->attribs;
$myimageurl=myimage($tmpattribs);
if ($myimageurl<>""){
echo '<img style="width:32px;height:32px" src="'.$myimageurl.'" title="'.$item->title.'" alt="'.$item->title.'" />';
}
Upload the file in :
PATH_TO_JOOMLA/templates/Your_Template/html/com_content/category
Now, edit or Insert a test article and type the url path image in the new field URL Image in Advanced parameter.
When Done, if we were lucky, we have to see somethink like the following image
- have fun -