Je crois avoir trouvé ma solution à vous de me dire ce que vous pensez de cette méthode.
1- J'ai localisé le fichié
Utilities.php qui se trouve dans le dossier
helpers de
com_k2, à la ligne 83 de ce fichier j'ai fonction
getCategoryImage
public static function getCategoryImage($image, $params)
{
jimport('joomla.filesystem.file');
$mainframe = JFactory::getApplication();
$categoryImage = NULL;
if (!empty($image))
{
$categoryImage = JURI::root(true).'/media/k2/categories/'.$image;
}
else
{
if ($params->get('catImageDefault'))
{
if (JFile::exists(JPATH_SITE.DS.'templates'.DS.$mainframe->getTemplate().DS.'images'.DS.'placeholder'.DS.'category.png'))
{
$categoryImage = JURI::root(true).'/templates/'.$mainframe->getTemplate().'/images/placeholder/category.png';
}
else
{
$categoryImage = JURI::root(true).'/components/com_k2/images/placeholder/category.png';
}
}
}
return $categoryImage;
}
A cette fonction là j'ai retiré l'execution après le 2e
ESLSE ce qui me donne donc
public static function getCategoryImage($image, $params)
{
jimport('joomla.filesystem.file');
$mainframe = JFactory::getApplication();
$categoryImage = NULL;
if (!empty($image))
{
$categoryImage = JURI::root(true).'/media/k2/categories/'.$image;
}
else
{
if ($params->get('catImageDefault'))
{
if (JFile::exists(JPATH_SITE.DS.'templates'.DS.$mainframe->getTemplate().DS.'images'.DS.'placeholder'.DS.'category.png'))
{
$categoryImage = JURI::root(true).'/templates/'.$mainframe->getTemplate().'/images/placeholder/category.png';
}
}
}
return $categoryImage;
}
2- Dans le fichier
category.php j'avais créer une div
CategoryHeader dans laquelle devrait apparaître l'image et la description de la catégorie.
Juste avant cette div j'avais ce code
<?php if($this->params->get('catImage') || $this->params->get('catDescription')): ?>
Code complet
[color=#ff0044]<?php if($this->params->get('catImage') || $this->params->get('catDescription')): ?>[/color]
<div class="CategoryHeader">
<?php if($this->params->get('catImage') && $this->category->image): ?>
<div class="catImage">
<img alt="<?php echo K2HelperUtilities::cleanHtml($this->category->name); ?>" src="<?php echo $this->category->image; ?>" style="width:<?php echo $this->params->get('catImageWidth'); ?>px; height:auto;" />
</div>
<?php endif; ?>
<?php if($this->params->get('catDescription')): ?>
<div class="catDescription"><?php echo $this->category->description; ?></div>
<?php endif; ?>
</div>
<?php endif; ?>
Alors j'ai conditionné l'affichage de cette nouvelle div que j'ai créer par la vérification qu'une image pour la catégorie à été uploader
[color=#ff0044]<?php if(isset($this->category->image)): ?>[/color]
<div class="CategoryHeader">
<?php if($this->params->get('catImage') && $this->category->image): ?>
<div class="catImage">
<img alt="<?php echo K2HelperUtilities::cleanHtml($this->category->name); ?>" src="<?php echo $this->category->image; ?>" style="width:<?php echo $this->params->get('catImageWidth'); ?>px; height:auto;" />
</div>
<?php endif; ?>
<?php if($this->params->get('catDescription')): ?>
<div class="catDescription"><?php echo $this->category->description; ?></div>
<?php endif; ?>
</div>
<?php endif; ?>
ET VOILA
AJMG