0
votes

I'm redesigning a client's top-level category pages and I would like to future-proof the design by making it dynamic. To further clarify, I want it so whenever the client adds, edits or removes a category below the current level, it would reflect that on the frontend without the need of editing code.

Now, I have come across some blog posts on the topic and even a Stack forum post: http://www.templatemonster.com/help/magento-listing-sub-categories-on-a-category-page.html how to display thumbnail from category using getThumbnailUrl() in Magento

However, these are both handling it differently. The Stack post also lead me to: http://www.douglasradburn.co.uk/getting-category-thumbnail-images-with-magento/

Which I found out I needed to add the functionality for pulling the Thumbnail Image (way to go Magento). BUT, this is what I need! The end goal here is to use the Thumbnail Image on the backend of the Category, NOT the Image. We're using the Image elsewhere, as intended. I also would like to be able to pull in the category description from the backend to the frontend for the purpose of adding some extra information such as links, a true description, etc.

If there anyone who can help me? I went through the above examples and links and still, the Thumbnail images were not pulling to the frontend and overall, I'm just getting some weird behaviour. Any tips would be appreciated as I research this further myself.

Thank you!

2

2 Answers

0
votes

Please Try below code. I have implemented the same with this

<?php $category_path          =    Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."catalog/category/"; ?>
<?php if (!Mage::registry('current_category')) return ?>
<?php $_categories = $this->getCurrentChildCategories() ?>
<?php $_count = is_array($_categories)?count($_categories):$_categories->count(); ?>
<?php if($_count): ?>
    <div class="static-page-listing static-page-listing1">
        <ul class="products-grid">
            <?php $num = 0; ?>
             <?php foreach ($_categories as $_category): ?>
                 <?php if($_category->getIsActive()): 
                 $num++;
                    $selImage      =    "SELECT value FROM catalog_category_entity_varchar WHERE attribute_id = '126' AND entity_id = '".$_category->getId()."'";
                    $catImage      =    Mage::getSingleton('core/resource')->getConnection('core_read')->fetchOne($selImage);
                    if(!$catImage)  $catImage = "no_image.jpg"; ?>
                    <li class="category-item  <?php if($num%2==0) echo 'item-right'?>">
                        <a href="<?php echo $this->getCategoryUrl($_category) ?>">
                        <div style="float:left; width:100%;">
                                <img src="<?php echo $category_path.$catImage?>">
                        </div>
                        <div>
                            <h3><?php echo $this->htmlEscape($_category->getName()) ?></h3>
                            <h6 style = "color:red;">VIEW ALL</h6>
                        </div>
                         </a>
                    </li>

                 <?php endif; ?>
              <?php endforeach ?>
        </ul>
    </div>
<?php endif; ?>
0
votes

NEW UPDATE:

The below code works:

<?php echo $cur_category->getDescription(); ?>

However, you need to be sure to check your Scopes! Not realizing my individual Store Scopes were not checked off to follow the "All Scopes" default, I fixed that and the above code worked for me when added to the "DESCRIPTION" area!

Thanks Stack!

PREVIOUS UPDATE:

I now have code working that I found online, it involved me adding a function to pull the category thumbnail image. It works! Here is the mark-up for the template:

<div class="category-products">
<ul class="products-grid">

        <?php
            $_categories=$this->getCurrentChildCategories();

            if($_categories->count()):
                $categorycount = 0;

            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 ($categorycount == 0){
                $class = "first";
            }

            elseif ($categorycount == 3){
                $class = "last";
            }

            else{
                $class = "";
            }
        ?>


    <li class="item <?=$class?>">
        <a href="<?php echo $cur_category->getURL() ?>" title="<?php echo $this->htmlEscape($cur_category->getName()) ?>">
            <img src="<?php echo $cur_category->getThumbnailUrl() ?>" width="100" alt="<?php echo $this->htmlEscape($cur_category->getName()) ?>" />
        </a>

        <h2>
            <a href="<?php echo $cur_category->getURL() ?>" title="<?php echo $this->htmlEscape($cur_category->getName()) ?>">
                <?php echo $this->htmlEscape($cur_category->getName()) ?>
            </a>
        </h2>

        <p>
            DESCRIPTION
        </p>
    </li>

        <?php
            endif;
            if($categorycount == 3){
                $categorycount = 0;

                echo "</ul>\n\n<ul class=\"products-grid\">";
            }

            else{
                $categorycount++;
            }

            endforeach;
            endif;
        ?>

</ul>

Now, where you see "DESCRIPTION," I would like to pull the category description data from the backend and have it output there. Basically, allowing dynamic creation/revision of top-level category pages.

How can I pull the description though? I'm not an expert in Magento, maybe I'm missing something basic but I can't get it working.

Thank you!