Reputation: 831
New to Magento (wordpress developer) and I'm struggling with this concept in Magento and not sure how to accomplish this with their api and set a varialbe of if body class = x
In short if the body has a class that is "x" then this happens (I'm trying target specific class's, so if a sub-page had a class of "other" for example, then it would run an if or elseif for that page):
<?php if ($this->getLayout()->createBlock("page/html")->getBodyClass() == 'home'): ?>
//add this content
<?php elseif($this->getLayout()->createBlock("page/html")->getBodyClass() == 'options'):?>
//add different divs content etc
<?php else: ?>
//stuff
<?php endif; ?>
Upvotes: 0
Views: 2303
Reputation: 1552
you can get the css class through
$this->getBodyClass()
used to work with block type
Mage_Page_Block_Html
otherwise
$this->getLayout()->createBlock("page/html")->getBodyClass();
Upvotes: 2
Reputation: 5211
<?php
$body_classes = $this->getLayout()->createBlock("page/html")->getBodyClass();
if($body_classes=='cms-index-index'):
//your code
elseif($body_classes=='cms-page-view'):
//your code
else:
//your code
endif;
?>
Upvotes: 0