Inserting CMS blocks in the iPhone Theme

Inserting CMS blocks in the iPhone Theme

How to show a CMS block in the mobile view?

 

By default, our iPhone Theme extension does not have a provision for inserting CMS content from the backend. But it is still possible to do so via minor code modifications.

 

The key of the method is to insert the block calls directly into the theme's template files.

 

Note, the blocks must be created prior to inserting them, as it is necessary to specify the exact block ID for every instance.

 

To insert a block into the home page only:

 

1. Navigate to the Magento root folder on your server, then open this file: app/design/frontend/aw_mobile/iphone/template/catalog/navigation/top.phtml


2. Insert the below code into the desired position: 


<?php echo Mage::app()->getLayout()->createBlock('cms/block')->setBlockId('block_identifier')->toHtml(); ?>


where "block_identifier" is the ID of your block.

 

There are 5 available positions, see below for details: 


#1. After <div id="home" class="header-nav current">

#2. After <div><?php echo $this->getChildHtml('nav_messages'); ?></div>

#3. Right after the following lines:
 <?php endforeach ?>
 </ul> 
(54 and 55 lines in default template)

#4. Right after the following lines:
 <div><ul class="messages"><li class="notice-msg"><ul><li><?php echo $this->__('There are no categories.'); ?></li></ul></li></ul></div>
 <?php endif; ?>
(58 and 59 lines of default template)

#5. After <?php echo $this->getChildHtml('navigation.newsletter'); ?>


Block positions

 

3. Flush the store and browser cache, and check your page.


HINT: since the described method requires specifying the block ID, it may be handy to create empty CMS blocks, and insert the calls into all the available positions. In such case, if you ever need to show any content is a currently unused position, you will be able to just fill the existent block from the backend.


To insert a block into all the catalog pages:

 

1. Open file app/design/frontend/aw_mobile/iphone/template/page/1column.phtml


2. Insert the below code in the desired position



<?php
if (Mage::registry(AW_Mobile_Block_Catalog_Navigation::IS_NAVIGATION_PAGE)){
echo Mage::app()->getLayout()->createBlock('cms/block')->setBlockId('block_identifier')->toHtml();
}?>


where "block_identifier"  is the ID of your block in Magento backend.

 

3. Flush store and browser cache, and check the page