开发者

Magento: Layout Changes using LOCAL XML ONLY

I'm pretty new to magento and I would like to customize the store front-end.

I'm using Magento 1.4.1 and I'm planning to do all design modifications on the local.xml of my new template.

My doubt is if it is possible to change the layout structure only using the local.xml. I mean without changing the phtml files.

A simple example of what I would like to be able is: I want to put the catalog search in another part of my html and not inside the , as it is today. So I would like to remove it from top-bar and put it inside another div.

<div class="top-bar">
<div class="breadcrumbs">
    <ul>
                    <li class="home">
                            <a href="http://www.domain.com/magento/" title="Ir para página principal">Principal</a>开发者_如何学JAVA
                                        <span>/ </span>
                        </li>
                    <li class="category9">
                            <strong>Product Category</strong>
                                    </li>
            </ul>
</div><!--breadcrumbs-->
<form id="search_mini_form" action="http://www.domain.com/magento/catalogsearch/result/" method="get">
    <div class="form-search">
        <label for="search">Pesquisar</label>
        <input id="search" type="text" name="q" value="" class="input-text" />
        <button type="submit" title="Ir" class="button"><span><span>Ir</span></span></button>
        <div id="search_autocomplete" class="search-autocomplete"></div>
        <script type="text/javascript">
        //<![CDATA[
            var searchForm = new Varien.searchForm('search_mini_form', 'search', 'Procurar em toda a loja...');
            searchForm.initAutocomplete('http://www.domain.com/magento/catalogsearch/ajax/suggest/', 'search_autocomplete');
        //]]>
        </script>
    </div>
</form>
</div>   <!--top bar-->

How do I accomplish this? Is it possible to use only local.xml?

Thanks in advance and best regards


The practical answer is "No, you can't do that".

What you want to do is theoretically possible, although the amount of work that would need to be done and the value of it would be questionable.  

You use local.xml to add, remove, and interact with Blocks.  Each phtml file has a parent block that corresponds to something in your layout.  You can't change how a phtml block is rendered via the Layout XML, unless the Block and phtml contain logic to allow this.

In theory, you could

  1. Identify the class responsible for rendering a particular template
  2. Create a new Block class that extends this class (not override)
  3. Change add code in local.xml to replace the block class 
  4. In your new block class override the view rendering method so it calls the parent view rendering method, and then attempts to alter the results of the returned string before returning its value

Again, all possible, but of questionable value.

Why the hesitancy to replace a phtml file from the default theme with a phtml file in your own theme(s)?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜