Magento add pager toolbar to wishlist - magento

Is it possible to use the catalog collection pager for the wishlist, and if so how can I implement this into the wishlist?

danny (OP) already self-answered the question.
Quote:
Ok, i've found the solution here but i'll post it here too for a better code highlighting:
Create a new modul and overwrite the wishlist block located in: code/core/Mage/Wishlist/Block/Customer/Wishlist.php
and add the following to your 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');
}
}
now add <?php echo $this->getPagerHtml(); ?> to the start and/or end of the view.phtml located in: app/design/frontend/default/your_theme/template/wishlist/view.phtml. that should do the trick.
Note: It's absolutely OK to self-answer your own question. Please just post it as an real answer, but not in a question or comment. Posting as real answer helps to keep the "Unanswered" list more clear (avoids making other people wasting their time).

you do not need to create a new module.just create (with folder) in your local : app\code\local\Mage\Wishlist\Block\Customer\Wishlist.php.and enter the following code on 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');
}
}
After that add following code in /app/design/frontend/base/default/template/wishlist/view.phtml
<?php echo $this->getPagerHtml(); ?>
after title div and after formkey in end of view.phtml
: image example
tested on Magento ver. 1.9.0.1

Related

Magento 1.9 custom admin grid load inside itself

I have 2 grids in the same module (and i need to keep them in the same module).
When i click on the top of the column the grid load itself inside itself.
Below is my code:
Myname_Blink_Adminhtml_BlinkController
public function keywordsAction()
{
$this->loadLayout();
$this->_setActiveMenu('blink/keywords');
$this->_addContent($this->getLayout()->createBlock('Myname_Blink_Block_Adminhtml_Keywords_Grid'));
$this->renderLayout();
}
my block file : Myname_Blink_Block_Adminhtml_Keywords_Grid extends
class Myname_Blink_Block_Adminhtml_Keywords_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
public function __construct()
{
parent::__construct();
$this->setId('keywords_grid');
$this->setDefaultSort('keywords_id');
$this->setDefaultDir('ASC');
//$this->setSaveParametersInSession(true);
$this->setUseAjax(true);
}
As suggested to this post: Multiple grid in Magento admin
I removed the files:
=>Myname_Blink_Block_Adminhtml_Keywords
=>app\design\adminhtml\default\default\layout\myname\blink.xml
Maybe something goes wrong with AJAX call.
Did you try this one:
http://davemacaulay.com/fix-issue-with-magento-adminhtml-grid-ajax-call-containing-the-whole-page/
public function keywordsAction()
{
if($this->getRequest()->isXmlHttpRequest()) {
$this->getResponse()->setBody($this->getLayout()->createBlock('Myname_Blink_Block_Adminhtml_Keywords_Grid')->toHtml());
return $this;
}
$this->loadLayout();
$this->renderLayout();
}
Good luck!!!

Show Pagination in Category Listing Page

I have created a custom phtml file for categories in which i am listing child categories of parent category.
I want to show pagination tool bar in that category listing is there anyway to do that?
you can set collection in _preparelayout function as below code in your block file
protected function _prepareLayout()
{
parent::_prepareLayout();
$toolbar = $this->getLayout()->createBlock('page/html_pager');
if ($toolbar) {
$toolbar->setAvailableLimit(array(10=>10,20=>20,'all'=>'All'));
$toolbar->setCollection($this->getCollection());
$this->setChild('toolbar', $toolbar);
}
return $this;
}
public function getToolbarHtml()
{
return $this->getChildHtml('toolbar');
}
and call in your phtml file by
$this->getToolbarHtml();

Magento custom cache issue on product view page

We added the custom cache for product view page.
We rewrite the view.php file and write below code :
<?php
/**
* Rewriting Product View block
*/
class XXX_YYY_Block_Catalog_Product_View extends Mage_Catalog_Block_Product_View
{
protected function _construct()
{
$this->addData(array(
//'cache_key' =>
//'cache_lifetime' =>
'cache_tags' => array(Mage_Catalog_Model_Product::CACHE_TAG . "_" . $this->getProduct()->getId()),
));
}
public function getCacheKey()
{
if (!$this->hasData('cache_key')) {
//$cacheKey = LAYOUTNAME_STORE+ID_PRODUCT+ID
$cacheKey = $this->getNameInLayout().'_STORE'.Mage::app()->getStore()->getId().'_PRODUCT'.$this->getProduct()->getId();
//.'_'.Mage::getDesign()->getPackageName().'_'.Mage::getDesign()->getTheme('template'). //_PACKAGE_THEME ?
$this->setCacheKey($cacheKey);
}
return $this->getData('cache_key');
}
public function getCacheLifetime()
{ //to prevent sub-blocks caching
if($this->getNameInLayout()!='product.info') return null;
//return false; //false creates default lifetime (7200)
return 9999999999;
}
}
?>
After the rewrite code added the add to cart functionality and global messages not working in product view page.
Help to fix this issue.
Thanks

Joomla Plugin Content Hook Not working

I am new to joomla. I am trying to learn some extension development. I already have experience in WordPress themes and plugins. I want to filter a phone number in an article and show it in a appropriate manner. For this I have written test plugin code, but it is not filtering. I have even tried to put an exit statement in the onContentPrepare() hook but it is not working.
/**
* #package Joomla.Plugin
* #subpackage Content.ClicktoCall
* #since 3.0
* #version 1.0.0
*/
defined('_JEXEC') or die;
jimport('joomla.plugin.plugin');
class eqlContentClicktoCall extends JPlugin {
public function onContentPrepare($context, &$row, &$params, $page = 0) {
// Don't run this plugin when the content is being indexed
exit();
if ($context == 'com_finder.indexer') {
return true;
}
if (is_object($row)) {
return $this->clicktocall($row->text, $params);
}
return $this->clicktocall($row);
}
protected function clicktocall(&$text) {
$pattern = '/(\d{4})(\d{3})(\d{4})/';
$replace = "+92-$1-$2-$3";
$text=preg_replace($pattern, $replace, $text);
return true;
}
}
How can I get this hook to work?
You need to change your class name, there's a syntax which if not followed, will cause the plugin to not be triggered. Rename like so:
class plgContentClicktoCall extends JPlugin
In addition, there's rules for how to build out your manifest for installing the plugin.
http://docs.joomla.org/Manifest_files
http://svn.joomla.org/project/cms/development/trunk/tests/_data/installer_packages/plg_system_alpha/alpha.xml

how to add grid under a tab in magento custom admin module?

I want to create a grid in my custom module under a tab section as like would show up under customer ->wish list tab.
Assuming that your using Method 3 # http://www.nextbits.eu/blog/how-to-add-tab-in-customer-information-in-magento-admin/
class Namespace_ModuleName_Block_Adminhtml_Customer_Tab
extends Mage_Adminhtml_Block_Template
implements Mage_Adminhtml_Block_Widget_Tab_Interface {
/**
* Set the template for the block
*
*/
public function _construct()
{
parent::_construct();
$this->setTemplate('modulename/customer/tab.phtml');
}
in modulename/customer/tab.phtml
<?php
echo $this->getLayout()
->createBlock('modulename/adminhtml_modulename_grid')
->toHtml();
?>

Resources