gpt4 book ai didi

php - Magento - 检查 cms 页面

转载 作者:可可西里 更新时间:2023-10-31 22:54:40 27 4
gpt4 key购买 nike

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

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

问候里托

最佳答案

下面应该给你你想要的

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

当这返回字符串“cms”时,您位于 CMS 页面上。

当 Magento 的前端和管理路由器无法在您的 URL 上找到匹配项时,CMS 路由器就会接管。如果 CMS 路由器找到匹配项(基于您设置的 CMS 页面),它会将请求传递给 cms 模块和 Mage_Cms_IndexController Controller 。

关于php - Magento - 检查 cms 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3477893/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com