Page 1 of 1

Show category image on article page

Posted: Fri Jul 04, 2008 4:25 pm
by brythnoth
We need to show the category image on article page, found a work around by not showing the intro text and placeing the category image at the top of the main text but then the article title shows above the image.

I have seen a much older post on this same topic with no reply's, I hope someone has an answer as I've been working on this for a week solid and lost two nights kip!

Thanks in advance

Jeff

Re: Show category image on article page

Posted: Mon Jul 14, 2008 10:23 am
by alexmcca
Hi there,
Sorry not to be posting a solution, but did you find any answer to this as I am trying to do exactly the same thing?

Thanks very much,
Alex.

Re: Show category image on article page

Posted: Wed Mar 25, 2009 11:37 am
by lamis
there isnt an exact solution but what I did was ( work only for front end though -still you can find the right file to make it work on all articles-)
this is NOT the best solution but thats what I did at least
1- Created new folder in media manager called it categories
2- upload pictures to that folder and name them the same as categories with jpg extension
3- went to templates/mycurrentTemplate/html/com_content/frontpage/default_item.php
4- added this
<img src="images/categories/<?= $this->item->category ?>.jpg">

Re: Show category image on article page

Posted: Fri Aug 07, 2009 1:02 pm
by xabo
hello, where in the php-file should i put in the code? Any specific line?

thanks

Re: Show category image on article page

Posted: Sat Mar 06, 2010 11:07 am
by eriksmith200
thanks for the tip!

Re: Show category image on article page

Posted: Sun May 30, 2010 5:50 am
by lasangre
Check this extension.

It allows you to display a specific category description and/or image on a module position for corresponding articles (it can be set to do it automatically).

http://extensions.joomla.org/extensions ... I7fQ%3D%3D

Re: Show category image on article page

Posted: Wed Jul 28, 2010 10:02 pm
by eckounlimited
Hi there... I got there by using this:

<img src="<?
$secid = $this->item->catid;
$this->section = & JTable::getInstance( 'category' );
$this->section->load( $secid );
$cparams = JComponentHelper::getParams ('com_media');
echo $cparams->get('image_path').'/'.$this->section->image;
?>">

Thanks for the module tip, I took a small code snipped from the module, looked through the joomla sources and finally found to this solution.

Lars

Re: Show category image on article page

Posted: Sat May 07, 2011 7:38 am
by paskuale
hello guys how can I use this module within the new article form (front end) ?

thanks :eek:

Re: Show category image on article page

Posted: Wed Dec 07, 2011 10:09 am
by alvarpoon
in Joomla 1.6, to show the category image in an article, it should be

$secid = $this->item->catid;
$category = JCategories::getInstance('Content')->get($secid);
if ($category->getParams()->get('image')):?>
<img src="<?php echo $category->getParams()->get('image'); ?>"/>
<?php endif; ?>

Re: Show category image on article page

Posted: Thu Dec 29, 2011 10:44 pm
by TheBestLooser
Good evening,

there is there a code to display the image of the category in the article for joomla 1.7 / 2.5?

Thank you in advance

Re: Show category image on article page

Posted: Sun Jan 15, 2012 11:54 am
by boredmind
I would like the same in Joomla 1,7 does anyone know how to do this? thank you

Re: Show category image on article page

Posted: Thu Mar 01, 2012 7:12 pm
by mhdzn
use this code.. it works in 2.5 and 1.7

Code: Select all

<a href="<?php echo $this->item->category->link; ?>"><img alt="<?php echo $this->item->category->name; ?>" src="media/k2/categories/<?php echo $this->item->category->image; ?>" border="0"/></a>

Re: Show category image on article page

Posted: Thu Aug 28, 2014 3:35 am
by modernmagic
Its great when you can use info from an old post and joomla version on the latest.

I used this to display the category image in an article:

Code: Select all

<div class="catimage">
	<?php
$secid = $this->item->catid;
$category = JCategories::getInstance('Content')->get($secid);
if ($category->getParams()->get('image')):?>
<img src="<?php echo $category->getParams()->get('image'); ?>"/>
<?php endif; ?>
</div>