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>
1
  • could you please let me know what exactly you want? do you want category thumbnail and small image or all data?
    – Dexter
    Commented Jul 4, 2014 at 12:28

1 Answer 1

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
  • 1
    Note: Missed a ' in 'catalog/category
    – Tisch
    Commented Dec 7, 2015 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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