5

I have created a new page template here:

/template/page/category.phtml

and copied inside the content of 1column.phtml.

What I want to accomplish is to get the category data variable in this new template.

Any help would be greatly appreciated.

<html>
<head>
<?php echo $this->getChildHtml('head') ?>
</head>
<body>

<!-- Instead of getting the category content through the function below, I want to get it without this function-->
<?php echo $this->getChildHtml('content') ?>

</body>
</html>
  • could you please let me know what exactly you want? do you want category thumbnail and small image or all data? – Dexter Jul 4 '14 at 12:28
11

you need to load category on your template. Either by factory method(as shown here) or in your block instantiation( {{block }} or xml block ). I hope this code snippet will help.

$_helper    = $this->helper('catalog/output');
$_category  = Mage::getModel('catalog/category')->load(CATEGORYID);// get your category here.
$_imgHtml   = '';
if ($_imgUrl = $_category->getImageUrl()) {
    $_imgHtml = '<p class="category-image"><img src="'.$_imgUrl.'" alt="'.$this->htmlEscape($_category->getName()).'" title="'.$this->htmlEscape($_category->getName()).'" /></p>';
    $_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
    echo $_imgHtml;
}
  • 1
    Note: Missed a ' in 'catalog/category – Tisch Dec 7 '15 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.