News:

Looking for documentation? Take a look on our wiki

Main Menu

show category image in mod_virtuemart_category in Virtuemart 2 (Solved)

Started by simplyClear, July 05, 2012, 13:06:30 PM

Previous topic - Next topic

simplyClear

Hello,

This is my first post.

I've been looking for support in order to display in each category link their respective image in the "all.php override archive".

I also want to know how can i customize each menu item with css, i.e: their respective color

I found a solution in this post, but I'm afraid the changes will disappear when updating VM2:

https://forum.virtuemart.net/index.php?topic=100995.0

Help me, please...

simplyClear

This is my own answer:

1.- First, In the all.php override archive, I put an Id calling to "$cattext" var in the "li div":

This is the original all.php archive:

<li <?php echo $active_menu ?>>   
   <div>
      <?php echo JHTML::link($caturl, $cattext); ?>
   </div>

This is the all.php override archive:

<li <?php echo $active_menu ?>>   
   <div id="item<?php echo $cattext ?>">
      <?php echo JHTML::link($caturl, $cattext); ?>
   </div>

2.- Second, I made the CSS instruction:
color, background image, font-size, etc.

I hope this will be useful for somebody...

isalcedo

How do you Did for display the Images in the mod_virtuemart_category? Sorry for my english. I need to do it. Im just a Web Designer, no a programmer.  :-\ but i can read and apply simple PHP

simplyClear

Hola Isalcedo,

Perfecto, entonces te respondo en castellano.
Siento no haberte respondido ayer pero ya había salido de la oficina.

Supongo que te refieras al módulo que muestra las categorías de Virtuemart, y que quieres mostrar alli las imágenes correspondientes a cada categoría.

Bien, el caso es que primero debes seleccionar la plantilla "all" en el módulo de virtuemart que hayas creado en tu sitio desde el backend.

Una vez realizado esto y luego de sobre-escribir el archivo "all.php" en:
TU_PLANTILLA/html/mod_virtuemart_category/all.php

Como dicen en este enlace:
http://forum.virtuemart.net/index.php?topic=90935.0

Debes abrir el archivo y alli encontrarás esto (código por defecto):


<?php // no direct access
defined('_JEXEC') or die('Restricted access');
JHTML::stylesheet 'vmsite-ltr_euskexpbox.css''templates/euskexpbox/css/'false );
?>


<ul class="menu<?php echo $class_sfx ?>" >
<?php foreach ($categories as $category) {
 
$active_menu '';
$caturl JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$category->virtuemart_category_id);
$cattext $category->category_name;
//if ($active_category_id == $category->virtuemart_category_id) $active_menu = 'class="active"';
if (in_array$category->virtuemart_category_id$parentCategories)) $active_menu 'class="active"';

?>


<li <?php echo $active_menu ?>>
<div>
<?php echo JHTML::link($caturl$cattext); ?>
</div>
<?php if ($category->childs ) {


?>

<ul class="menu<?php echo $class_sfx?>">
<?php
foreach (
$category->childs as $child) {

$caturl JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$child->virtuemart_category_id);
$cattext $child->category_name;
?>

<li>
<div ><?php echo JHTML::link($caturl$cattext); ?></div>
</li>
<?php ?>
</ul>
<?php  ?>
</li>
<?php
?>

</ul>


Aqui los desarrolladores crearon una variable al principio de esta manera (en el archivo original, línea 11):
$cattext = $category->category_name;

(Esa es la variable que llama al nombre que tu le has puesto a cada categoría)

Lo que hice fué llamar a esa variable desde el div que contiene a las categorías, o sea cambiar esto:

<li <?php echo $active_menu ?>>   
   <div>
      <?php echo JHTML::link($caturl, $cattext); ?>
   </div>

Por esto:

<li <?php echo $active_menu ?>>   
   <div id="item<?php echo $cattext ?>">
      <?php echo JHTML::link($caturl, $cattext); ?>
   </div>

Si te fijas, se llama a la varible con código php. Luego, tu desde tu archivo CSS (usando el firebug, ubicas como se llama cada categoría) le pones una imagen de fondo que tu quieras a cada categoría.

No es la mejor solución que existe, ni yo soy un experto en PHP tampoco, pero me ha solucionado mi necesidad.

Espero que ta haya ayudado, cualquier duda me dices.

Saludos.