2013-10-09 77 views
1

我正在嘗試使用分頁創建自定義集合頁面。我已經在塊中創建了分頁代碼,並可以在模板中輸出它。 但是,我創建的模塊具有其他模板沒有分頁的頁面。Magento block per action

工作原理:用戶轉到index.php/styles/choose/items並選擇他想要顯示的產品的屬性/類別。他點擊提交,並被重定向到index.php/styles/choose/products,在那裏他可以看到產品和分頁。

在我styles.xml我有

<styles_choose_items> 
     <reference name="root"> 
      <action method="setTemplate"><template>page/1column.phtml</template></action> 
     </reference> 
     <reference name="content"> 
      <block type="styles/styles" name="styles" template="styles/styles.phtml"/> 
     </reference> 
    </styles_choose_items> 
    <styles_choose_products> 
     <reference name="root"> 
      <action method="setTemplate"><template>page/1column.phtml</template></action> 
     </reference> 
     <reference name="content"> 
      <block type="styles/products" name="products" template="styles/products.phtml"/> 
     </reference> 
    </styles_choose_products> 

在config.xml中我有:

<blocks> 
     <styles> 
      <rewrite> 
       <styles>Nuvo_Styles_Block_Styles</styles> 
      </rewrite> 
      <rewrite> 
       <products>Nuvo_Styles_Block_Products</products> 
      </rewrite> 
     </styles> 
</blocks> 

在控制器:

public function itemsAction() 
{ 
    $this->loadLayout(); 
    $this->renderLayout(); 
} 

public function productsAction() 
{ 
    $this->loadLayout(); 
    $this->renderLayout(); 
} 

我真的想知道是什麼我做錯了。 index.php/styles/choose/items頁面可以正確顯示,但index.php/styles/choose/products只顯示模板,如果我嘗試向Products.php塊添加任何內容,它將變爲空白且沒有錯誤。

任何幫助表示讚賞。

謝謝!

+0

激活php的錯誤顯示和Magento的開發者模式:這種方式你會看到錯誤,從而明白出了什麼問題,第一步到解決方案 – OSdave

+0

嗨。我已經激活了Magento中的錯誤日誌並添加了error_reporting(E_ALL | E_STRICT); ini_set('display_errors',1);到PHP文件,但我無法找到任何日誌,並沒有顯示錯誤。 – sias

回答

1

你的配置中的blocks的聲明是錯誤的,你不重寫塊,據我所知。試試這個:

<blocks> 
     <styles> 
      <class>Nuvo_Styles_Block</class> 
     </styles> 
    </blocks> 

而且它會看到Nuvo_Styles_Block_Products

0

感謝您的反饋非常有用。我在index.php中啓用了第77行ini_set('display_errors',1);查看錯誤。 我其實非常接近。 Products.php塊文件中只有一個錯誤。它現在可以正常工作。