Magento-检查cms页面 [英] Magento - check if cms page

查看:70
本文介绍了Magento-检查cms页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过php检查页面是否是Magento中的cms_page.我需要针对cms页面的不同面包屑,所以我尝试有条件地做到这一点,但我不知道如何或在哪里看. 到目前为止,这是我的Breadcrumbs.phtml.

i want to check via php if a page is a cms_page in Magento. I need diffrent breadcrumbs for cms pages, so im trying to this with a condition, but i have no idea how to or where to look at. Heres my breadcrumbs.phtml so far.

<?php if(this is a cms page): ?>

<p>some content</p>
<?php else: ?>
<?php if($crumbs && is_array($crumbs)): ?>
<div class="breadcrumbs">
    <ul>
    <?php $charsges = 0; ?>
    <?php foreach($crumbs as $_crumbName=>$_crumbInfo): ?>
        <?php
        $charsges = strlen($_crumbInfo['label']) + $charsges;
        if($charsges > 40){
            $chars = 18;
            if(strlen($_crumbInfo['label']) > $chars){
                $_crumbInfo['label'] = substr($_crumbInfo['label'], 0, $chars);
                $_crumbInfo['label'] = $_crumbInfo['label'].'..';
            }
        }
        ?>
        <li class="<?php echo $_crumbName ?>">
        <?php if($_crumbInfo['link']): ?>

        <a href="<?php echo $_crumbInfo['link'] ?>" title="<?php echo $this->htmlEscape($_crumbInfo['title']) ?>"><?php echo $this->htmlEscape($_crumbInfo['label']) ?></a>
        <?php elseif($_crumbInfo['last']): ?>
        <strong><?php echo $this->htmlEscape($_crumbInfo['label']) ?></strong>
        <?php else: ?>

        <?php echo $this->htmlEscape($_crumbInfo['label']) ?>
        <?php endif; ?>
        <?php if(!$_crumbInfo['last']): ?>
        <span>&nbsp;&gt;&nbsp;</span>
        <?php endif; ?>
        </li>
    <?php endforeach; ?>
    </ul>
</div>
<?php endif; ?>

向里托致意

推荐答案

以下内容应为您提供所需的内容

The following should give you what you want

//from a block or phtml script
$this->getRequest()->getModuleName()

当它返回字符串"cms"时,您位于CMS页面上.

When this returns the string 'cms', you're on a CMS page.

当Magento的前端和管理路由器在您的URL上找不到匹配项时,CMS路由器将接管.如果CMS路由器找到匹配项(基于您已设置的CMS页面),它将请求转交给cms模块和Mage_Cms_IndexController控制器.

When Magento's frontend and admin routers can't find a match on your URL, the CMS router takes over. If the CMS router finds a match (based on the CMS pages you've setup), it hands off the request to the cms module and Mage_Cms_IndexController controller.

这篇关于Magento-检查cms页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆