Reputation: 13
Under the design tab of a CMS page in Magento's admin area, there is the option to specify a page layout. I have a few custom fields that I wish to display only on certain page layouts. How can I grab the name of the page layout so I can proceed with an if statement for displaying my custom fields? Thanks in advance!
Upvotes: 1
Views: 2983
Reputation: 1261
$root = Mage::app()->getLayout()->getBlock('root');
if ($root)
{
$rootTemplate = $root->getTemplate();
switch ($rootTemplate )
{
case 'page/2column.phtml':
// Do something.
break;
//etc.
}
}
Upvotes: 4
Reputation: 196
Congrats on finding your solution, but this may help you out moving forward: http://www.magentocommerce.com/magento-connect/magneto-debug-8676.html
I find it useful at times.
Upvotes: 1