Question

I added a new page layout in my store and now when I want add another page layout it's replaced with the previously added layout.

Why does this happen? Can't I make more than one layout?

EDIT: I added in app/code/local/Home/Page/etc/config.xml :

<?xml version="1.0"?>
<config>
  <modules>
    <Home_page>
      <version>0.1.0</version>
    </Home_page>
  </modules>
  <global>
    <page>
      <layouts>
        <homepage translate="label">
          <label>Home_page</label>
          <template>page/homepage.phtml</template>
          <layout_handle>home_page</layout_handle>
        </homepage>
        <!-- add more layouts here -->
      </layouts>
    </page>
  </global>
</config>

Also added app/etc/Home_page.xml:

<?xml version="1.0"?>
<config>
  <modules>
    <Home_page>
      <active>true</active>
      <codePool>local</codePool>
      <depends>
        <Mage_Page />
      </depends>
    </Home_page>
  </modules>
</config>

And add this app/design/frontend/default/my-theme/template/page/homepage.phtml , that I use my layout in this page.

Was it helpful?

Solution

You did not show how you added more layouts, but I suspect, what's the problem:

    <homepage translate="label">
      <label>Home_page</label>
      <template>page/homepage.phtml</template>
      <layout_handle>home_page</layout_handle>
    </homepage>

The layout handle home_page as well as the element name <homepage> must be unique. So if you add additional layouts, and you use <homepage> again, it overrides the previously added <homepage> layout.

OTHER TIPS

Your activation file is wrong. it should look like this

File : app/etc/Home_Page.xml:

<?xml version="1.0"?>
<config>
  <modules>
    <Home_Page>
      <active>true</active>
      <codePool>local</codePool>
      <depends>
        <Mage_Page />
      </depends>
    </Home_Page>
  </modules>
</config>

ie You should use Home_Page instead of Home_page everywhere.

Your config file should be

File: app/code/local/Home/Page/etc/config.xml :

<?xml version="1.0"?>
<config>
  <modules>
    <Home_Page>
      <version>0.1.0</version>
    </Home_Page>
  </modules>
  <global>
    <page>
      <layouts>
        <homepage module="Home_Page" translate="label">
          <label>Home Page</label>
          <template>homepage/unique.phtml</template>
          <layout_handle>home_page</layout_handle>
        </homepage>
        <!-- add more layouts here -->
      </layouts>
    </page>
  </global>
</config>

You had same problem in this file too.

There is couple of things which lags in your module. They are :

  1. you should define a layout update xml file for your module : Use this file to define the custom page handle of yours. For more details, you can refer in app\design\frontend\base\default\layout\page.xml. There see the definition of page_one_column layout handle. You need such definition for home_page inside your own layout update xml file.

  2. You should define the page layout template file. According to the modifications that I have shown above, you should define that file at app\design\frontend\base\default\template\homepage\unique.phtml. Use app\design\frontend\base\default\template\page\1column.phtml as reference for this.

Good luck

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top