Magento has this facility built-in. You just want to use that. For this, login into admin section of your site, go to CMS > Pages > [Select your CMS Page] > Design
tab and choose 2column-right
layout from there.
If the CMS Page has any custom layout set in the above section, then layout update that you have mentioned is never going to apply, since your changes has overwritten by the in-built facility that I have described above. So use the default feature. Simple and elegant.
EDIT
Your layout update is not working because, all of your cms pages updates that you have done through the layout update handle cms_page
are overwritten by it's higher levels1 updates. Most probably, all of your CMS Pages has their own root template which set via backend (you can find this setting at CMS > Pages >[any cms page] > Design > layout
). If you want to overcome this higher level layout update, the only possible way is listening to a special event cms_page_render
.
Event Registration
File : app\code\local\Namespace\Module\etc\config.xml
<config>
<frontend>
<events>
<cms_page_render>
<observers>
<namespace_module>
<class>rkt_seo/observer</class>
<method>changeCMSPageTemplate</method>
</namespace_module>
</observers>
</cms_page_render>
</events>
</frontend>
<global>
<models>
<namespace_module>
<class>Namespace_Module_Model</class>
</namespace_module>
</models>
</global>
</config>
Observer
File : app\code\local\Namespace\Module\Model\Observer.php
<?php
class Namespace_Module_Model_Observer
{
const PAGE_EMPTY = 'empty';
const ONE_COLUMN = 'one_column';
const TWO_COLUMN_RIGHT = 'two_columns_right';
const TWO_COLUMN_LEFT = 'two_columns_left';
const THREE_COLUMN = 'three_columns';
public function changeCMSPageTemplate(Varien_Event_Observer $observer)
{
$action = $observer->getEvent()->getControllerAction();
$update = $action->getLayout()->getUpdate();
$helper = $action->getLayout()->helper('page/layout');
$pageLayout = $helper->getCurrentPageLayout();
if ($pageLayout !== false) {
$update->removeHandle($pageLayout->getLayoutHandle());
}
$helper->applyHandle(self::TWO_COLUMN_RIGHT);
return $this;
}
}
Theory
cms_page_render
is fired after applying CMS Page specific page layout handle. In your case page_one_column
layout update handle will get added. What we need is, we need to remove this layout update handle and then add our own page layout update handle, ie page_two_column_right
. Observer will doing that job here.
Note 1: This update will affect all CMS Pages irrespective of the value at the layout section of a cms page (backend) under Design
tab.
Note 2 : Since this observer overwrite admin layout template functionality, the only way to overwrite the changes that we have done via observer is using custom layout xml section comes under Design
tab of each cms page. That means if you need to use a special page layout other than 2 column right
for a specific CMS Page, then you should use the above section to do that.
Note 3 : If you have further doubts on how to setup the module, then you can use this.
1 : Higher level may be a layout update handle which is process after cms_page
(eg: cms_page_view
or cms_index_index
, page_one_column
etc). It also includes root templates that we set via admin section (ie under CMS > Pages >[any cms page] > Design > layout
). It can also be the specific layout updates that you have specified in the xml section of a CMS Page.