1

这是我的代码:

<?php
    $_rtl           = Mage::getStoreConfig('custom_menu/general/rtl') + 0;
    $_categories    = $this->getStoreCategories();
    if (is_object($_categories)) $_categories = $this->getStoreCategories()->getNodes();
?>
<div class="nav-container">
<div style="z-index:999;position:relative;top:-8px;left:979px;cursor:pointer;"><img src="<?php echo $this->getSkinUrl('images/Truck-Prince-text.png'); ?>" height="91" width="123" style="position:absolute;" onclick="location.href='<?php echo Mage::getUrl('checkout/cart'); ?>'"></div>
    <div id="custommenu" class="<?php echo $_rtl ? ' rtl' : ''; ?>">
        <?php if ($this->showHomeLink()) : ?>
        <div class="menu">
            <div class="parentMenu menu0">
                <a href="<?php echo $this->getUrl('') ?>">
                    <span><?php echo $this->__('Home'); ?></span>
                </a>
            </div>
        </div>
        <?php endif ?>
        <?php foreach ($_categories as $_category): ?>
            <?php echo $this->drawCustomMenuItem($_category) ?>
        <?php endforeach ?>
    <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('nav-links-after')->toHtml() ?>
        <div class="clearBoth"></div>
    </div>
</div>

我想要做的是这样的事情,但我不知道如何在不导致错误的情况下插入它。我基本上想用字符串替换的urls来改变现有的url..

<?php // We must replace URLs on the fly to use landing pages and not break subcat navigation
    $_category = str_replace('wild-bird-feed-supplies.html', 'landing-wild-bird-feed-supplies', $_category);
    $_category = str_replace('lawn-garden-supplies.html', 'landing-lawn-garden-supplies', $_category);
    $_category = str_replace('pet-food-supplies.html', 'landing-pet-food-supplies', $_category);
    $_category = str_replace('animal-feed-supplies.html', 'landing-animal-feed-supplies', $_category); ?>
4

1 回答 1

0

我终于能够得到它:)这就是我所做的......

<?php
    $_rtl           = Mage::getStoreConfig('custom_menu/general/rtl') + 0;
    $_categories    = $this->getStoreCategories();
    if (is_object($_categories)) $_categories = $this->getStoreCategories()->getNodes();
?>
<div class="nav-container">
<div style="z-index:999;position:relative;top:-8px;left:979px;cursor:pointer;"><img src="<?php echo $this->getSkinUrl('images/Truck-Prince-text.png'); ?>" height="91" width="123" style="position:absolute;" onclick="location.href='<?php echo Mage::getUrl('checkout/cart'); ?>'"></div>
    <div id="custommenu" class="<?php echo $_rtl ? ' rtl' : ''; ?>">
        <?php if ($this->showHomeLink()) : ?>
        <div class="menu">
            <div class="parentMenu menu0">
                <a href="<?php echo $this->getUrl('') ?>">
                    <span><?php echo $this->__('Home'); ?></span>
                </a>
            </div>
        </div>
        <?php endif ?>
        <?php foreach ($_categories as $_category): ?>
            <?php $_category = $this->drawCustomMenuItem($_category) ?>

    <?php // We must replace URLs on the fly to use landing pages and not break subcat navigation
    $_category = str_replace('wild-bird-feed-supplies.html', 'landing-wild-bird-feed-supplies', $_category);
    $_category = str_replace('lawn-garden-supplies.html', 'landing-lawn-garden-supplies', $_category);
    $_category = str_replace('pet-food-supplies.html', 'landing-pet-food-supplies', $_category);
    $_category = str_replace('animal-feed-supplies.html', 'landing-animal-feed-supplies', $_category); ?>

    <?php echo $_category; ?>


        <?php endforeach ?>
    <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('nav-links-after')->toHtml() ?>
        <div class="clearBoth"></div>
    </div>
</div>
于 2013-03-28T01:18:34.883 回答