Adding pager to custom collection block - magento

Sorry for the redundancy of this question, but none of the example and solutions have worked for me. I have a custom module that extends Mage_Catalog_Block_Product_List. The only function in it is _getProductCollection which sets the product collection based on which attribute you want to filter on. It's pretty simple and there are no layout updates involved. I put the block on the page by putting the following into the Content section of a CMS page:
{{block type="vps_featured/list" name="vps_featured_list" attribute_name="best_sellers" template="catalog/product/sale_list.phtml"}}
Since it extends Mage_Catalog_Block_Product_List, I get all the bells and whistles for a product list page, including the toolbar. However, the pager isn't there. I've tried a number of different suggestions but none have helped.
I looked in Toolbar.php in the core code and found where it calls getPagerHtml. I put some debug statements in there and determined that it calls this function when putting my custom block on the page but $this->getChild('product_list_toolbar_pager') is not returning the block, presumably because it isn't there. I tried adding the block using a layout update XML file and adding the <frontend><layout><updates>... tags to my config, but this didn't seem to do anything.
I have Alan Storm's CommerceBug extension, so I pulled that up and exported the layout XML for the page. It doesn't contain any toolbar block at all, despite the fact that the toolbar is on the page and only the pager isn't working. If I do the same thing on a category landing page, it shows the toolbar block in the layout xml. So I've clearly missed something here, but I'm at a loss as to what. I hope someone can help :)
Brian

As it turns out, the solution found HERE works great! You have to add the block using the Layout Update XML rather than adding it in the content section. I still don't quite understand why, but it works.

There already was question about Getting pager to show on magento list

Related

How do I display "News" on the Home page? (Magento)

I need news articles to be displayed on the front page but the standard way, to put this code {{block type="profile/profile" name="profile" template="profile/news-front.phtml"}} in the editor on backend doesn't work, even though I have created file news-front.phtml in the template/profile. I really-really need help with this. The output in system.log is Not valid template file:frontend/base/default/template/profile/news-front.phtml
Is the block type really going to be profile/profile? If you are just hoping to output the file as PHP/HTML you may want to consider using core/template rather than profile/profile.

Magento get which layout being used on phtml files

Is there a way I could get which layout being used on a certain phtml files?
Here in my case, I want to check what layout being used on catalog/list.phtml, I used that information to make conditional "if" on the product image grid size.
I've tried to google it out. But all the result is just explaining about xml layout things. The closest clue I got is this thread
Magento get layout for given page
which stated the use of this snippet
$left_block = $this->loadLayout()->getLayout()->getBlock('left');
but when I tried it on the phtml files, I got an exception error
UPDATE
joe's answer below has give me some more clue, the exception gone. But the behavior doesn't really what I need. That snippet of code seems to be just check whether the specified block is defined on the XML. What I really need is whether that block exist on a certain page.
In my case, I need to check what layout being used on catalog/product/list.phtml. if it's 3 columns, I'm gonna make the image resized smaller. If it 1 column, I'll make it bigger.
Is there any way I could do that??
If I read the question correctly, then try:
$this->getLayout()->getBlock('root')->getTemplate();
Remove loadLayout():
$left_block = $this->getLayout()->getBlock('left');
By the time you are in the PHTML file, the layout is already loaded.
In PHTML files, $this refers to the Mage_Core_Block_Template class (or a class that extends it). This class doesn't have a loadLayout() method defined, which is why you get an exception; instead, loadLayout() is part of Mage_Core_Controller_Varien_Action.

Pinpointing the difference and changes made between two pages in magento 1.6.2

I have two pages that should be using the exact same template and layout.
The correct item layout can be seen below.
http://dokha.co/index.php/medwakh/custom-medwakh-from-white-horse-studios-13.html
The incorrect item layout is below.
http://dokha.co/index.php/shisha-tobacco/al-fakher-shisha-tobacco-1.html
As you can see in the first image the layout of the item is compact. In the second link it is all drawn out.
I am curious to know if you can tell me how to make the second one like the first one, The compact style. I am not sure what modifications could have been made in magento to cause the layout to only show up that way for specific items, as only the items in the category on link 1 behave that way, I would like to know how to make them all behave this way.
Ok, first thing: the layouts are slightly different because in the first example, you have simple product and in the second example you have a configurable product.
So, view.phtml is including different templates in each.
Regardless though, the actually culprit of the expanded space you are seeing in the second example is being caused by a clearing div. Simply remove it.
The div you are looking for is this:
<div class="clearer"></div>
and you will find it in app/design/frontend/your_package/your_theme/template/catalog/product/view.phtml

Joomla 1.5 / Modification of YooTheme "ZOO" Component

I'll start out by mentioning that there is a developer forum for Zoo and I have used it already. My purpose posting here is that I typically get a thorough answer within minutes or hours at SO, whereas the responses on dev forums can be slow or non-existent due to the smaller population base.
My question regards Yootheme's ZOO 2.3.2. By default, a product "Frontpage" appears to have a "Categories" box rendered on top of the items. If one turns off all the available options in Frontpage/Template configuration (hide Titles, Count, Descriptions, etc.), an empty box still remains on top of the items.
I've been able to manually remove the box in its entirety by addressing the following file:
media/zoo/applications/product/templates/default/frontpage.php, and commenting out lines 84-92:
<!-- <?php
// render categories
if ($this->category->childrenHaveItems()) {
$categoriestitle = $this->application->getParams()->get('content.categories_title');
echo $this->partial('categories', compact('categoriestitle'));
}
?> -->
Seems like there should be a more eloquent way of doing this on the admin backend, but I couldn't find one. Am I missing something or is my solution the best one?
ZOO is designed to easily be able to modify the built in templates to suit your needs. ZOO templates are meant to be overridden much like Joomla uses template overrides. Rather than editing the default template, you simply create a new template that does what you want it to. The default template should not be changed.
Here is the documentation on ZOO templates - http://www.yootheme.com/docs/home/item/create-a-new-template
Rather than edit the file you mention above, you make a new template here -
media/zoo/applications/product/templates/YOUR-TEMPLATE-NAME/frontpage.php
Then do all the changing you want without messing up the default.
There is an easier way: First, you must identify what calls the item called "frontpage". In PURE yootheme at least it is called from "home" in the "mainmenu". So click "home" buton of the mainmenu, then over the right menu "Parameters(Basic)" you just chose "-select aplication-" instead "frontpage" and that's it.The Frontpage and its "box" are now gone. At least it works for me.

Paginating a long list of checkboxes in Magento

it would be awesome if someone could help me with this - I've already spent more than a day on it. :(
In a phtml file in Magento, I'm displaying a long list of products with a checkbox next to each. I've already added some code to paginate this list. The problem is, when I move to say page 2, I need to 'remember' which boxes were selected in page 1, and select them when I move back to page 1. I know how to use javascript to detect if a checkbox is checked or not. I was planning to save an array of selected boxes in the magento session - adding to it when more boxes are checked and deleting when boxes are unchecked. But my session-changing code is PHP, and my checkbox-detector is javascript. I know I can't call my session-changing function from javascript - I've been told that I would need AJAX to do this. I don't know any AJAX at all. Is there any other way to do this?
I'd be happy to post relevant snippets of my code if anyone can help me. Thanks!
UPDATE:
Okay, so I decided to use AJAX after all, and I've added a lot of AJAX code already. The problem is, it's not working. Btw, I'm not using jQuery. When I write this in Magento:
xmlhttp.open("POST", 'adjust_session.php', true); xmlhttp.send(params);
exactly where do I need to put my adjust_session.php file? It's not working if I put it in the same folder as my phtml file (where I'm calling the open function).
Thanks!
How are you actually doing the pagination? If you have to make a round-trip to the server for the paginated data anyway, send a list of checked/unchecked with it and toggle in the session. Then, when rendering the new page, either check the boxes in the HTML directly, or just pass a list of currently checked boxes in as JS and parse it on the response.
Alternatively, if you are doing everything on one page (and using AJAX for pagination already), you could also hold onto an array in JS and recheck the boxes after you render them.
Hope that helps!
Thanks,
Joe

Resources