views:

228

answers:

1

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

greets rito

+3  A: 

The following should give you what you want

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

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

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.

Alan Storm
thanks, ill try on monday.
Rito
worked perfect! Thanks a lot.
Rito