0

我正在尝试从搜索栏正下方的页脚链接中移动 magentos 高级搜索链接。

我知道链接的来源在参考名称 =“footer_links”下的 layout/catalogsearch.xml 中,并且由于getChildHtml('footer_links')在 footer.phtml中而出现在页脚中

而且我知道搜索栏来自 template/catalogsearch/form.mini.phtml 并通过catalogsearch.xml在参考名称=“top.menu”下出现

关于如何在这里进行的任何想法?

4

2 回答 2

3

谢谢你的快速回答!但这并不是我想要的,因为它会在搜索栏下方显示整个页脚链接块。不过,感谢您向我展示您使用的方法!

无论如何,我自己想出了一个解决方案:

我修改了catalogsearch.xml:

<default>
    <reference name="top.menu"> 
        <block type="core/template" name="top.search" as="topSearch" template="catalogsearch/form.mini.phtml"/> 
    </reference>


<!-- add a new reference to top.search including my new adv.search block -->
    <reference name="top.search"> 
        <block type="page/template_links" name="adv.search" as="adv.search" >

            <action method="addLink" translate="label title" module="catalogsearch"> 
                <label>Advanced Search</label>
                <url helper="catalogsearch/getAdvancedSearchUrl" />
                <title>Advanced Search</title>
            </action>       

        </block>
    </reference>  
<!-- the reference to the footer i commented out as its not longer needed; it includes advanced search and popular search terms-->
</default>

在 form.mini.phtml 中,我添加了一个名为 adv.search 的新 div:

</script>

<div class="adv-search"> <?php echo $this->getChildHtml('adv.search') ?> </div>

</div>

最后,在 styles.css 中,我添加了一些代码来控制该 div 的外观:

.adv-search {width:100px; height:15px; margin-top:24px; margin-left: 120px;}
.adv-search a { color:#fff; font-weight:bold; }

任何额外的建议都非常受欢迎

干杯!

于 2012-09-12T11:30:55.177 回答
0

为了使它起作用,您必须:

1) 更新您的 app/design/frontend/[yourtheme]/default/layout/local.xml 文件

2) 调用 app/design/frontend/[yourtheme]/default/template/page/html/header.phtml 中的新块 - 这是必需的,因为 header.phtml 不是自动呈现其的“core/text_list”块类型嵌套块。所以我们必须明确告诉 Magento 渲染那些子块

您的 app/design/frontend/[yourtheme]/default/layout/local.xml 应包含以下内容:

<?xml version="1.0"?>
<layout version="0.1.0">

    <default>

        <reference name="header">

            <!-- Insert cms links. No need to use <action method="insert"> as this block is not used elsewhere in layout -->
            <block type="cms/block" name="top_links_cms" as="top_links_cms" before="top_links_other">
                <action method="setBlockId"><block_id>footer_links</block_id></action>
            </block>

            <!-- Insert former footer links. -->
            <action method="insert">
                <!-- We must keep block name "footer_links" as it is used as a reference for adding links by other modules -->
                <blockName>footer_links</blockName>
                <!-- Name of the block we want to have as sibling (in order to get its position and place our block after it. See next node <after> -->
                <siblingName>topSearch</siblingName>
                <!-- $after param from Mage_Core_Block_Abstract::insert() is a boolean type, so its value in the XML node is [empty], 0 or 1 -->
                <after>1</after>
                <alias>top_links_other</alias>
            </action>
        </reference>

        <reference name="footer">
            <action method="unsetChild"><name>footer_links</name></action>
            <action method="unsetChild"><name>cms_footer_links</name></action>
        </reference>

    </default>

</layout>

这是一个更新的 header.phtml,您可以从中获得灵感,用于您的 app/design/frontend/[yourtheme]/default/template/page/html/header.phtml 文件:

<div class="header-container">
    <div class="header">
        <?php if ($this->getIsHomePage()):?>
        <h1 class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a></h1>
        <?php else:?>
        <a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a>
        <?php endif?>
        <div class="quick-access">
            <?php echo $this->getChildHtml('topSearch') ?>



            <?php
            /**
             * Add other top links (footer and cms links)
             */
            ?>
            <?php echo $this->getChildHtml('top_links_cms') ?>
            <?php echo $this->getChildHtml('top_links_other') ?>



            <p class="welcome-msg"><?php echo $this->getWelcome() ?> <?php echo $this->getAdditionalHtml() ?></p>
            <?php echo $this->getChildHtml('topLinks') ?>
            <?php echo $this->getChildHtml('store_language') ?>
        </div>
        <?php echo $this->getChildHtml('topContainer'); ?>
    </div>
</div>
<?php echo $this->getChildHtml('topMenu') ?>
于 2012-09-11T20:47:17.800 回答