2013-03-05 49 views
1

我有一個類別在我的商店,需要一個完全不同的佈局,以標準的Magento佈局。所以,我創建了1column.phtml的新副本和renaked並做出一個小的變化進行測試:Magento添加新的頁面佈局類別使用

前端/測試/默認/模板/頁/ 1column-lookbook.phtml

<?php 
/** 
* Template for Mage_Page_Block_Html 
*/ 
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>"> 
<head> 
<?php echo $this->getChildHtml('head') ?> 
</head> 
<body<?php echo $this->getBodyClass()?' class="'.$this->getBodyClass().'"':'' ?>> 
<?php echo $this->getChildHtml('after_body_start') ?> 
<div class="container"> 
    <?php echo $this->getChildHtml('global_notices') ?> 
    <div class="page"> 
     <?php echo $this->getChildHtml('header') ?> 
     <div class="page_content"> 
      <div class="row"> 
       <div class="sixcol"> 
        <?php echo $this->getChildHtml('breadcrumbs') ?> 
       </div> 
       <div class="sixcol last"> 

       </div> 
      </div> 
      <div class="row"><h3>Filter here</h3></div> 
      <div class="row"><h3>Scrolling content</h3></div> 
      <div class="row"> 
       <div class="main-content"> 
        <?php echo $this->getChildHtml('global_messages') ?> 
        <?php echo $this->getChildHtml('content') ?> 
       </div> 
      </div> 
      <?php echo $this->getChildHtml('footer') ?> 
      <?php echo $this->getChildHtml('before_body_end') ?> 
     </div> 
    </div> 
</div> 
<?php echo $this->getAbsoluteFooter() ?> 
</body> 
</html> 

但是我似乎無法讓我的目錄看到這個,我試着在page.xml和layout.xml文件中添加對它的引用。但是,不管我嘗試過什麼,我似乎無法讓它顯示int他的頁面佈局下拉爲我的類別。

回答

1

Magento Module for new CMS layout, but in version 1.7.0.2

http://www.magentocommerce.com/boards/viewthread/285425/#t400446

很多在那裏對這個..

在您的自定義模塊XML配置添加一些條目添加到您的新佈局

<config> 
    <modules> 
     <My_Module> 
      <version>0.0.0.1</version> 
     </My_Module> 
    </modules> 
    <global> 
    <page> 
     <layouts> 
      <my_layout module="page" translate="label"> 
       <label>My Layout</label> 
       <template>page/mylayout.phtml</template> 
       <layout_handle>my_layout</layout_handle> 
      </my_layout> 
     .... 

不要忘記刷新您的緩存後

+0

這兩個都是專門爲CMS頁面,這是否也將添加到類別以及可用? – 2013-03-05 17:19:52

+0

是應該正常工作 – Andrew 2013-03-05 17:23:20

2

當你在Magento搜索「1column.phtml」字符串,你會發現:

應用程序/代碼/核心/法師/頁的/ etc/config.xml中
第45行上,你會發現配置你需要

現在你可以把相同的配置結構,自己的模塊中像這樣:

<global> 
    <page> 
     <layouts> 
      <test module="page" translate="label"> 
       <label>The test</label> 
       <template>page/test.phtml</template> 
       <layout_handle>page_test</layout_handle> 
      </test> 
     </layouts> 
    </page> 
</global> 

刷新Magento的緩存,去你的貓egory編輯屏幕=>自定義設計=>頁面佈局,然後選擇剛添加到下拉菜單中的模板。

希望這會有所幫助。

0

查找:/App/etc/local.xml

就在</global>標籤,把多餘的頁面佈局配置。

<page> 
    <layouts> 
    <lookbook module="page" translate="label"> 
     <label>LOOK BOOK</label> 
     <template>page/1column-lookbook.phtml</template> 
     <layout_handle>page_lookbook</layout_handle> 
    </lookbook> 
    </layouts> 
</page> 

這就是它。 :)

+0

如何在magento中添加多個自定義佈局? – 2015-07-17 06:31:14

-1

所以更好的方式來創建一個新的佈局。

http://www.sundataplus.com/adding-a-new-page-layout-to-magento-1-x/

該文件可以被編輯:應用程序/代碼/核心/法師/頁的/ etc/config.xml中 添加..之間新線與其他佈局一起。

<page> 
     <layouts> 
. 
. 
     <home module="page" translate="label"> 
      <label>Home</label> 
      <template>page/home.phtml</template> 
      <layout_handle>page_home</layout_handle> 
     </home> 
. 
. 
     </layouts> 
</page> 

創建新文件:模板/頁/ home.phtml與1column.phtml一起,2columns-left.phtml等。你可以複製在家裏的列布局PHTML之一的現有代碼。 PHTML。根據需要修改home.phtml中的代碼。