Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Include .html file in category description
 
redzephyr
Jr. Member
 
Total Posts:  10
Joined:  2012-11-06
 

I have not been able to find a solution to this so hopefully someone has an answer for me. Is it possible to add an include of any sort to a category page either in the category description section or to a static block that is attached to that category? If so what would be the syntax?

I have attempted several variations of this code:
{{block type=’core/template’ template=’media/catalog/pages/custom-html-page.html’}}

I have placed this code in a static block and added it to the category, I’ve also added the above code directly to the category description area within the actual category and no luck.

Can anyone help me? I am in need of adding custom html content to many of these category pages and to save time I need to be able to build them locally and then simply call the files rather than uploading each one to the category page.

Any help would be greatly appreciated.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Lyonscg
Sr. Member
 
Avatar
Total Posts:  173
Joined:  2009-11-13
Chicago IL
 

This code will add the static block “block_identifier” to your category view. Just change the block_identifier to your static block’s identifier.

echo $this->getLayout()->createBlock('cms/block')->setBlockId('block_identifier')->toHtml();
 
Magento Community Magento Community
Magento Community
Magento Community
 
redzephyr
Jr. Member
 
Total Posts:  10
Joined:  2012-11-06
 

This code will add the static block “block_identifier” to your category view. Just change the block_identifier to your static block’s identifier.

echo $this->getLayout()->createBlock('cms/block')->setBlockId('block_identifier')->toHtml();

Not really sure where I should be placing this, would this go in the static block below the code I already have or in the category description?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Lyonscg
Sr. Member
 
Avatar
Total Posts:  173
Joined:  2009-11-13
Chicago IL
 

I apologize, for whatever reason I thought you were editing the category view file directly. You can’t call a static block through the category description. The only way to use a static block in a category is to change the display settings.

Catalog -> Categories -> Manage Categories -> Select category (left col) -> Display Settings (tab, right col)

Display Mode: Either Static block only or static block and products.
CMS Block: Select static block

This is the only way to do it through the admin panel.

You could also go to app/design/frontend/PACKAGE/THEME/template/catalog/product/list.phtml and insert another static block using the code I posted earlier anywhere on the page (left/right column excluded). This approach requires understanding of both the xhtml and some basic php.

There is one other option which requires assigning the block to the layout.xml, but in my opinion is the most technical and complicated of the three options and unless requested, I’ll skip the instructions on this one.

I hope this helps

 
Magento Community Magento Community
Magento Community
Magento Community
 
redzephyr
Jr. Member
 
Total Posts:  10
Joined:  2012-11-06
 

Thanks Lyons CG

I did think there was a bit of confusion based on your initial reply, I’ve been able to get to the point where I have a static block created and using it as the content for the category, however my original problem is the same, I cannot get my html file to be included within the static block via the code options I have tried. If you could confirm whether this is possible using something similar to the following code I would be very thankful.

{{block type='core/template' template='http://domain.com/magento/media/catalog/pages/custom_page.htm'}}
 
Magento Community Magento Community
Magento Community
Magento Community
 
Lyonscg
Sr. Member
 
Avatar
Total Posts:  173
Joined:  2009-11-13
Chicago IL
 

Haha, I am so sorry it took me so long to realize what you are trying to do.

You can include phtml (and possibly html) files from your theme\’s template directory in static blocks using the code you posted.

All you need to do is move your file it to this location:

app/design/frontend/PACKAGE/THEME/template/page/custom/ (create the custom directory)

and then call the file like so:

{{block type=\"core/template\" template=\"page/custom/custom-html-page.phtml\"}}

If you absolutely need to use the html file and can’t include it directly as shown above, you will need to create a custom phtml somewhere in the template directory and use PHP to include your html file into the phtml file

<?php
    
include('http://');
?>

and then call the phtml file into the static block with the code above. This is incredibly sloppy though and I can\’t think of a reason why you couldn\’t just move the html to the phtml file and location.

If you get a chance, can you let us know if including html works or if you have to use phtml?

Thanks, good luck

 
Magento Community Magento Community
Magento Community
Magento Community
 
redzephyr
Jr. Member
 
Total Posts:  10
Joined:  2012-11-06
 

Thanks for the help, this worked perfectly, and it did by the way work with both the .phtml and the .html files no problems.

You have saved me a bunch of time, Thanks again!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top