【发布时间】:2011-10-23 01:30:15
【问题描述】:
是否可以将目录集合寻呼机用于愿望清单,如果可以,我如何将其实现到愿望清单中?
【问题讨论】:
-
@denny:为我遇到的相同问题 +1。
是否可以将目录集合寻呼机用于愿望清单,如果可以,我如何将其实现到愿望清单中?
【问题讨论】:
danny (OP) 已经自行回答了问题。
引用:
好的,我找到了解决方案 here,但我也会将其发布在这里,以便更好地突出显示代码:
创建一个新模块并覆盖位于以下位置的愿望清单块:code/core/Mage/Wishlist/Block/Customer/Wishlist.php
并将以下内容添加到您的 Wishlist.php
class Company_Wishlist_Block_Customer_Wishlist extends Mage_Wishlist_Block_Customer_Wishlist
{
protected function _prepareLayout()
{
parent::_prepareLayout();
$pager = $this->getLayout()
->createBlock('page/html_pager', 'wishlist.customer.pager')
->setCollection($this->getWishlist());
$this->setChild('pager', $pager);
$this->getWishlist()->load();
return $this;
}
public function getPagerHtml()
{
return $this->getChildHtml('pager');
}
}
现在将 <?php echo $this->getPagerHtml(); ?> 添加到位于 app/design/frontend/default/your_theme/template/wishlist/view.phtml 的 view.phtml 的开头和/或结尾。这应该可以解决问题。
注意:这绝对是OK to self-answer 你自己的问题。请把它作为一个真正的答案发布,但不是在问题或评论中。发布为真实答案有助于使“未回答”列表更加清晰(避免让其他人浪费时间)。
【讨论】:
您不需要创建新模块。只需在本地创建(带有文件夹):app\code\local\Mage\Wishlist\Block\Customer\Wishlist.php。
然后输入以下代码Wishlist.php
<?php class Mage_Wishlist_Block_Customer_Wishlist extends Mage_Wishlist_Block_Abstract {
/**
* Preparing global layout
*
* @return Mage_Wishlist_Block_Customer_Wishlist
*/
protected function _prepareLayout()
{
parent::_prepareLayout();
$pager = $this->getLayout()->createBlock('page/html_pager', 'wishlist.customer.pager');
$pager->setAvailableLimit(array(5=>5,10=>10,20=>20,'all'=>'all'));
$pager->setCollection($this->getWishlist());
$this->setChild('pager', $pager);
$this->getWishlist()->load();
return $this;
}
/**
* Pager HTML
*
* @return HTML
*/
public function getPagerHtml()
{
return $this->getChildHtml('pager');
}
}
然后在 /app/design/frontend/base/default/template/wishlist/view.phtml 中添加以下代码
<?php echo $this->getPagerHtml(); ?>
在 view.phtml 末尾的 title div 和 formkey 之后 :image example
在 Magento 版本上测试。 1.9.0.1
【讨论】: