0

Magento 的新手(wordpress 开发人员),我在 Magento 中为这个概念而苦苦挣扎,不知道如何用他们的 api 来实现这一点并设置一个 if body class = x 的变量

简而言之,如果主体有一个“x”类,那么就会发生这种情况(我正在尝试针对特定类,所以如果子页面有一个“其他”类,例如,那么它将运行 if 或 elseif该页面):

<?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; ?>
4

2 回答 2

2

你可以通过

$this->getBodyClass()

用于块类型

  Mage_Page_Block_Html

否则

    $this->getLayout()->createBlock("page/html")->getBodyClass();
于 2014-01-08T06:34:02.223 回答
0
<?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;
      ?>      
于 2014-01-08T06:38:35.577 回答