Friday, September 10, 2010

How to easily display Magento cms pages in the home page using Static blocks



  • display links of your cms pages within a static block
  • use footer.phtml as the container for all the static blocks that we'll create

Files to modify:
  • footer.phtml
  • page.xml (optional)
  • styles.css (for styling the blocks)

-------------------------------------------------------------------------------------



First go to your magento backend.

  • create a page in CMS/PAGES (then take note of the url key-> we'll use that in the static block)
  • then create a new static block in CMS/STATIC BLOCKS
  • in the create static block page - take note of the identifier (we'll use that for making our block appear at the home page)
  • now to insert a link of your cms page in the static block insert this code

<a href="{{store direct_url="url-key-from-the-cms-page"}}">Title-Of-The_link</a>

--------------------------------------------------------------------------------------

Modify the footer.phtml and put something linke this:

<div class="footer-links">
<div class="footer-block">
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('bestellen')->toHtml() ?>
</div>
</div>

NOTE: Remember the identifier that I told you to take note? put that inside the setBlockId('identifier-here')
-------------------------------------------------------------------------------------

Modify the page.xml (optional)

if you want to clear the contents of the footer just comment out the <blocks> inside the main <block>

<block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml">
<block type="page/html_wrapper" name="bottom.container" as="bottomContainer" translate="label">
<label>Page Footer</label>
<action method="setElementClass"><value>bottom-container</value></action>
</block>
<!-- <block type="page/switch" name="store_switcher" as="store_switcher" template="page/switch/stores.phtml"/>
<block type="page/template_links" name="footer_links" as="footer_links" template="page/template/links.phtml"/>
<block type="page/template_links" name="bestellen" as="bestellen" template="page/template/bestellen.phtml"/>-->
</block>

--------------------------------------------------------------------------------------
you can style your blocks by giving it a class and defining the class in styles.css

We're done! Hope this helps!

No comments:

Post a Comment