建站资讯

magento主题风格开发设计: 怎样搜索一个block

作者:admin 发布时间:2020-11-21

Separate the SEO links at the footer area - Instead of having the link items to be one list, isolate Advanced Search to be in the header instead.


Which module and layout file assigns a content block to a page is sometimes a little harder to find at first, especially if that block appears on every page in the header or the footer. But you can make a calculated guess that the SEO links are likely controlled by the catalog or catalogsearch modules or you can see that they are part of the footer structural block and open up layout/page.xml and look through the list of children under the footer block in order to locate a block that calls the footer links - you will find block name= footer_links , which is what calls the SEO links. Now that you know that layout updates reference the SEO links via the name= footer_links, now you will do a search in all the xml files for reference name= footer_links . You will find references for the footer_links block in catalog.xml (which calls Site Map ), catalogsearch.xml (which calls Search Terms and Advanced Search ) and contacts.xml (which calls Contact Us ).

从控制模块或layout file找一个block是较为艰难的。但還是一些方式: 例如要搜索seo links,将会在footer一部分,那么就去page.xml找到,发觉了footer_links

-----------------------

实例:把advance search从footer挪到header

1. Whatever method you use, once you have located the area of the individual SEO link items, you will now begin the steps to isolate Advanced Search from the bunch and make it its own thing in the header.
2. Copy any files you will need to modify over to your custom theme.
3. First go to your copied page.xml and create a new block

block type= page/template_links name= header_links as= header_links template= page/template/links.phtml /
and nest it inside block name= header .

This makes the layout updates o to expect this link in header.phtml.

4. In the case of the header.phtml file, Magento is hard-coded to look for that filename, so let s just edit the template file directly in our custom theme for this example. Open your /header.phtml, and type in
?=$this- getChildHtml( header_links )?
where you want the link to reside.
5. Now go to catalogsearch.xml, and ment out this code:

action method= addLink translate= label title module= catalogsearch label Advanced Search /label url helper= catalogsearch/getAdvancedSearchUrl / title Advanced Search /title /action
from reference name= footer_links .

This will remove the link from the footer.
6. Still in catalogsearch.xml, create a new reference to the new header_links block and nest the cut out code inside it like so:

reference name= header_links action method= addLink translate= label title module= catalogsearch label Advanced Search /label url helper= catalogsearch/getAdvancedSearchUrl / title Advanced Search /title /action /reference


7. Reload the frontend store to see your changes. We now have Advanced search in the header instead of the footer.

-----------

 

 


收缩