I am trying to customize a Blanco Magento Theme I bought in Themeforest,
I want to display some categories (not all) in the front page with an static image, does anyone have an idea how to do it?
Thanks a lot!
PS: Magento is 1.7
This can be easily done if you need to display products on home page or any CMS page then do the following:
a) Create a new category of the products which you want to display on the desired page and note down the category Id generated (suppose id = 4)
b) Go to Admin->CMS->Pages and select the page you want
For adding any image add an img tag with the below src
src="{{media url="image_path"}}"
{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="4" template="catalog/product/list.phtml"}}
that's it
Hope this helps!!
You can put the following Code into a PHTML file and include it in your Front Page using XML or other way you want. As far as static image is concern, you can add Category image from Admin which will be display from the given code -
CODE is :
<?php
# CategoryIDs to be display on Front Page...
$_viewCategories = array(3, 4, 5);
# Categories Counter...
$counter = count($_viewCategories);
# Get Category Model
$getCategoryModel = Mage::getModel('catalog/category');
?>
<div class="categoryList">
<?php
for($i = 0; $i < $counter; $i++)
{
// Load Categories...
$getCategoryModel->load($_viewCategories[$i]);
$getParentCategoryName = $getCategoryModel->getName();
# echo "Parent Category Name : ".$getParentCategoryName;
?>
<div class="categoryListContainer">
<div class="categoryListHeading"><?php echo ucwords(strtolower($getParentCategoryName)); ?></div>
<?php
$getChildren = $getCategoryModel->getChildren();
$subCategories = explode(",", $getChildren);
$j = 0;
foreach ($subCategories as $_child) {
if($j >= 2){ break; }
?>
<div style="float:left; width:205px; <?if($j == 1):?>margin-left:25px;<?php endif; ?>" align="center">
<?php
$subCategoryDetail = Mage::getModel("catalog/category")->load($_child);
echo "<a href='".$subCategoryDetail->getUrl()."' title='".$subCategoryDetail->getName()."'>";
echo "<div class='categoryListImg'><img src='".$subCategoryDetail->getImageUrl()."' height='120px' width='120px' alt='".$subCategoryDetail->getName()."' /></div>";
echo "<div class='categoryListCaption'>";
echo "<span class='catName'><span>".$subCategoryDetail->getName()."</span></span>";
echo "</div>";
echo "</a>";
?></div>
<?php
$j++;
}
?>
</div>
<?php
}
?>
</div>
It's Style you can manage with yourself with your own Style :)
Hope it would be helpful for you!
Thanks :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With