Ciao Gagliardi,
ho provato con il codice che mi hai segnalato, poi girando in rete ne ho trovato un altro che fa la stessa cosa ma apperentemente meglio! L'unico problema sia in questo che nell'altro script è che le immagine vengono prese dal campo immagine della categoria e non dal campo thumbanils. Puoi aiutarmi a modificare lo script e fargli prendere le immagini dal campo delle miniature?
1) Creato blocco statico chiamato subcategory_listing
{{block type="catalog/navigation" template="catalog/navigation/subcategory_listing.phtml"}}
Poi ho creato la pagina app/design/frontend/tuotema/default/template/catalog/navigaton/subcategory_listing.phtml e vi ho inserito questo codice:
Codice PHP:
<div id="categories">
<div class="col_full">
<div class="listing" >
<?php $_maincategorylisting=$this->getCurrentCategory()?>
<?php $_categories=$this->getCurrentChildCategories()?>
<?php if($_categories->count()):?>
<? foreach ($_categories as $_category):?>
<? if($_category->getIsActive()):
$cur_category=Mage::getModel('catalog/category')->load($_category->getId());
$layer = Mage::getSingleton('catalog/layer');
$layer->setCurrentCategory($cur_category);
$catName = $this->getCurrentCategory()->getName();
if($_imageUrl=!$this->getCurrentCategory()->getImageUrl()):?>
<div class="category-box">
<div class="category-image-box">
[url="<?php echo $this->getCategoryUrl($_category)?>"] [img]/skin/frontend/default/default/images/np_thumb2.gif[/img][/url]
</div>
<div class="category-name">
<a href="<?php echo $this->getCategoryUrl($_category)?>">
<?php echo $catName ?></a></p>
</div>
</div>
<?endif?>
<? if($_imageUrl=$this->getCurrentCategory()->getImageUrl()):?>
<div class="category-box">
<div class="category-image-box">
[url="<?php echo $this->getCategoryUrl($_category)?>"][img]<?php echo $_imageUrl?>[/img][/url]
</div>
<div class="category-name">
[url="<?php echo $this->getCategoryUrl($_category)?>"] <?php echo $_category->getName()?>[/url]</p>
</div>
</div>
<?
endif;
endif;?>
<?endforeach?>
<?php /* This resets the category back to the original pages category
**** If this is not done, subsequent calls on the same page will use the last category
**** in the foreach loop
*/ ?>
<?php $layer->setCurrentCategory($_maincategorylisting); ?>
<?endif;?>
</div>
<br clear=all>
</div>
</div>
e poi c'è il css per allineare la griglia:
codice:
.category-box {
float: left;
height: 200px;
margin-right: 6px;
width: 170px;
}
.category-image-box {
background-attachment: scroll;
background-clip: border-box;
background-color: transparent;
background-image: url("../images/category_image_bg.gif");
background-origin: padding-box;
background-position: 0 0;
background-repeat: no-repeat;
background-size: auto auto;
height: 104px;
width: 125px;
}
.category-image-box img {
padding-bottom: 0;
padding-left: 0;
padding-right: 0;
padding-top: 10px;
}
.category-name a:link, .category-name a:visited {
-moz-text-blink: none;
-moz-text-decoration-color: -moz-use-text-color;
-moz-text-decoration-line: none;
-moz-text-decoration-style: solid;
font-size: 12px;
font-weight: bold;
}
.category-name a:hover, .category-name a:active {
-moz-text-blink: none;
-moz-text-decoration-color: -moz-use-text-color;
-moz-text-decoration-line: underline;
-moz-text-decoration-style: solid;
font-size: 12px;
font-weight: bold;
}