0

This Magento newbie is trying to create a new page layout and customization for level 3 categories. What I've done at this point is use the Custom Design tab to change the Page Layout to 1 column and call a template with the Custom Layout Update:

<reference name="series">
    <action method="setTemplate"><template>catalog/category/seriespage.phtml</template></action>
</reference>

In my page.xml files I have the block defined as "core/template".

But what I found is that in my template I could not access the category fields with $this - calls to $this->getName() and $this-getDescription() returned null. I finally was able to get them this way:

$category = Mage::getSingleton('category/layer')->getCurrentCategory();
$desc = $category->getDescription();  // The right stuff

However, the category ID is still unknown and not returned from a $category->getCategoryId() call as I think it should be. I see references to $this->getCategoryId() often.

Now I want to fetch the content of a CMS static block I've created, but this too seems to return null. Nothing is output from a statement such as:

Mage::app()->getLayout()->createBlock('cms/block')->setBlockId->('my-block')->toHtml();

Using $this instead of Mage::app() didn't work either of course, and I tried other Mage variations. I thought defining this template in Manage Categories would give it the proper context, but apparently not. What am I missing to get $this to be set to my category context so the typical function calls work?

1 Answer 1

0

please check that your template is loaded with some static content

if yes then you can try below code for that

$_current_category = Mage::registry('current_category');
echo $_current_category->getName();
echo $_current_category->getDescription(); 

But in your case I am pretty sure that for series block type is different please update your question with your block type for series if my solution wont work. I will update my answer accordingly

4
  • Yes, my series.phtml template file has lots of content. I've been creating temp variables for the data for now and coding from that. Your Mage::registry example works, just like my Mage::getSingleton did. Is that a better method? In page.xml I have the block type as "core/template", as I noted in my original question.
    – twelvetone
    Commented Sep 30, 2016 at 0:07
  • yes use my one, and mark my answet accepted if it help you Commented Sep 30, 2016 at 0:40
  • Sure I'll use the registry call instead of getSingleton but it still doesn't answer my question. I want to be able to use $this in my template like other templates do, and I don't know why I cannot. And I still cannot get my CMS static block. Obviously I'm missing something...
    – twelvetone
    Commented Sep 30, 2016 at 1:55
  • please provide more detaail to your block type for that Commented Sep 30, 2016 at 2:33

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.