0

検索バーのすぐ下にあるフッター リンクから magentos の高度な検索リンクを移動しようとしています。

リンクの起点は、参照 name="footer_links" の下の layout/catalogsearch.xml にありgetChildHtml('footer_links')、footer.phtml にあるため、フッターに表示されることを知っています。

そして、検索バーが template/catalogsearch/form.mini.phtml から発生し、参照 name="top.menu" の下の catalogsearch.xml に表示されることを知っています

ここでどのように進めるかについてのアイデアはありますか?

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 に答える