如何将我的Magento mini搜索表单移动到模板标题中的另一个位置? [英] How to move my Magento mini search form to another spot in my template header?

查看:81
本文介绍了如何将我的Magento mini搜索表单移动到模板标题中的另一个位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立我的第一个自定义Magento主题.进展缓慢,但进展顺利.我摆脱了最初将迷你搜索表单保存在主页上的栏,而是希望将搜索表单放置在新标题中.

I am building my first custom Magento theme. It's slow going, but it is going. I got rid of the bar that originally held the mini search form on the home page and instead want to put the search form in my new header.

这是header.phtml中我标头的代码:

<div id="header">
<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>
    <div id="header-top">
    <?php echo $this->getChildHtml('topSearch') ?>
    <?php echo $this->getChildHtml('topLinks') ?>
    </div>
    <?php echo $this->getChildHtml('topMenu') ?>
</div>

但是搜索表单未呈现.这是有问题的网站:

But the search form is not rendering. Here is the site in question:

http://s1.mynewsitereview.com/

非常感谢!

推荐答案

首先,如果您没有local.xml文件,则需要创建或更新local.xml文件

First you need to create or update your local.xml file IF you do not have a local.xml file you can create one in

app-> frontend-> [程序包名称]-> [主题名称]->布局-> local.xml

app->frontend->[Package Name]->[Theme Name]->layout->local.xml

创建后,您可以将我在这篇文章中所拥有的内容完全复制到该文件中,以开始使用该文件的操作.

Once this is created you can copy exactly what I have in this post into that file for a start of how to use one.

不要通过catalog.xml通过LOCAL.XML文件进行所有更新!这将使以后的升级变得更加容易.此外,您将能够在一个文件中快速查看对网站所做的所有更改.

DO ALL UPDATES THROUGH A LOCAL.XML file not through catalog.xml !! This will make upgrades significantly easier later down the road. Additionally, you will be able to quickly see all changes you have made to your site in one file.

下面的示例将其添加到根引用名称中,该名称将在所有页面上可用,但可以在template-> page-> 1column.phtml或2column-left.phtml 3column.phtml等中轻松调用.

The below example will add it to the root reference name which will be available on all pages but easily called in template->page->1column.phtml or 2column-left.phtml 3column.phtml etc.

<?xml version="1.0" encoding="UTF-8"?>
<layout>
    <default>
        <reference name="root">
            <block type="core/template" name="top.search" as="topSearch" template="catalogsearch/form.mini.phtml"/>
        </reference>
   </default>
</layout>

然后使用您当前使用的方式进行调用.

Then call it using the way that you currently are using.

<?php echo $this->getChildHtml(‘topSearch’) ?>

现在,您可以像上一节一样使用引用名称"和"as"名称.例如,您可以使用下面的类似设置来引用页脚块以添加搜索功能.对于教育,.as"名称是.phtml文件中使用的名称. 名称"是在xml文件中引用块的方式.所以在上面的例子中.我将搜索字段添加到根内容区域,然后在我的.phtml文件中以"topSearch"的"as"名称调用它

Now you can use the "reference name" and "as" name like the above section. For example you could use the similar setup below to reference the footer block to add the search feature. For education "as" names are what are used in .phtml files. and "name" is how a block is referenced within xml files. So in the above example. I am adding the search field to the root content area and then calling it in my .phtml file with the "as" name of "topSearch"

<?xml version="1.0" encoding="UTF-8"?>
<layout>
    <default>
        <reference name="footer">
            <block type="core/template" name="footer.search" as="footerSearch" template="catalogsearch/form.mini.phtml"/>
        </reference>
    </default>
</layout>

然后使用

<?php echo $this->getChildHtml('footerSearch') ?>

这篇关于如何将我的Magento mini搜索表单移动到模板标题中的另一个位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆