lunes, 28 de octubre de 2013

Top menu vinculo varios colores / Top menu links with different colors

Modificar el archivo / Modify this file:
modules .>blocktopmenu > blocktopmenu.php

Tenemos que colorcar una clase a cada etiqueta LI del menú .
1. Necesitamos saber que LI pertenece al segundo nivel .
En la función private function getCategory tenemos la varialble $category->level_depth que indica el nivel de la categoría.

We need a class in the LI label
We need to know with LI belongs to the second level
In the function private function getCategory the variable $category->level_depth shows the category level.

Según las categoráis prestashop:
Acording to the prestashop category:

Inicio (Nivel 1)
      Cat(Nivel 2)
            Cat(Nivel 3)
      Cat(Nivel 2)
      Cat(Nivel 2)

Así que vamos a poner una condicion que discrimine los niveles 2. Dentro de la misma función sustituimos:
Introduce a condition to differentiate levels. In the same function replace:
$this->_menu .= '<. li '.$selected.'>';
por / to
if ($category->level_depth == 2){
                $this->_menu .= '<.li '.$selected.' class='aqui ira la clase /the style will place here'>';
                $this->contstile ++;
            }else{
                $this->_menu .= '<.li '.$selected.'>';
            }

        
2. Colocar el estilo que queremos. Inicializamos dos variables generales en la clase y colocamos debajo de las que hay:
Place the stile you want. Initialize two general variables and place beneath the actuals.
class Blocktopmenu extends Module
{
    private $_menu = '';
    private $_html = '';
    private $user_groups;


private $topstile= array('unotopmenu','dostopmenu','trestopmenu', 'cuatrotopmenu','cincotopmenu','seistopmenu','sietetopmenu' ,'ochotopmenu','nuevetopmenu','dieztopmenu','oncetopmenu'); <-- array="" br="" con="" estilos="" los="" name="" of="" style.="" the="" with="">
 private $contstile=0; <-- comment-----="" contador="" counter="">

Colocamos en el LI la clase que corresponde / Place in the LI at the class belonging.

if ($category->level_depth == 2){
                $this->_menu .= '<.li '.$selected.' class='.$this->topstile[$this->contstile].'>'; <-- br="" el="" estilo="" here="" inserta="" la="" moviendo="" moving="" nbsp="" place="" the="" variable.="" variable="">                $this->contstile ++;
            }else{
                $this->_menu .= '<.li '.$selected.'>';
            }



3. Colocar la clase de color que queremos en el css / Place the styles with the colocr in the CSS:
module>blocktopmenu>css>superfish-modified.css
.unotopmenu{  background-color:#C0F;}
.dostopmenu{background-color:#CC3;}
...




1 comentario:

  1. Viejo, que genial tu articulo, no te imaginas cuanto he buscado informacion al respecto y aqui la encontre casi que caida del cielo! Muchas gracias, la implementaré y te cuento de mis resultados

    ResponderEliminar