将Magento高级搜索链接从页脚移动到搜索栏下方

时间:2012-09-11 15:23:42

标签: magento advanced-search

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

我知道链接的起源位于layout / catalogsearch.xml下 引用名称=“footer_links”并显示在页脚中,因为footer.phtml中的getChildHtml('footer_links')

我知道搜索栏来自template / catalogsearch / form.mini.phtml,并通过参考名称=“top.menu”下的catalogsearch.xml显示

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

2 个答案:

答案 0 :(得分: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; }

非常欢迎任何其他建议

干杯!

答案 1 :(得分: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') ?>