1

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.

2
  • How did you add these layouts and where are they replaced? Aug 24, 2015 at 7:33
  • @fschmengler: please see my edit.
    – Elham Gdz
    Aug 24, 2015 at 7:50

2 Answers 2

1

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.

6
  • is there a default homepage layout exist in magento ? Aug 24, 2015 at 7:56
  • No, the default layouts from Mage_Page are: empty, one_column, two_columns, two_columns_left, two_columns_right and three_columns Aug 24, 2015 at 7:58
  • sorry confused with the last part of your answer. So it seems home_page is unique in this case. Please see my answer too. I put what I think about this as an answer :) Aug 24, 2015 at 8:06
  • Your answer worked, but I add a category and set it don't show in menu and redirect it to a page but the products that added in this category doesn't show, do you have any idea?
    – Elham Gdz
    Aug 24, 2015 at 8:29
  • I don't understand what this has to do with the page layout Aug 24, 2015 at 8:41
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.