Tag Archives: class

Custom Pagination in Symfony 2

Custom Pagination in Symfony 2

by ba1969/sxc.hu

NOTE: Tested on Symfony2 PR12. Might not work on later releases!
There is a newer version article about Symfony2 pagination that is compatible with Symfony2 – beta1.

Using Symfony 2, I noticed that there is no pagination included in framework (just some additional Bundle for download -and it uses Zend pagination but I don’t want to mix Zend into my Symfony 2 project), so I decided to write class for that on my own. Read more

4

Making use of Magento getSingleton method

Making use of Magento getSingleton method

In one of my previous articles I showed you how to use getModel and getData methods in Magento. Although we should not put those to methods at the same level, since I’d say the getModel is a bit more higher. Higher in sense, you first use the geModel to create the instance of object then you use getData to retrieve the data from that instance. I have said it before, and I’m saying it again; Magento is a great peace of full OOP power of PHP. It’s architecture is something not yet widely seen in CMS solutions.

One of the architectural goodies of Magento is it’s Singleton design pattern. In short, Singleton design pattern ensures a class has only one instance. Therefore one should provide a global point of access to that single instance of a class. Read more

14

Figuring out Magento object context

Figuring out Magento object context

One of the problems working under the hood of the Magento CMS is determining the context of $this. If you are about to do any advanced stuff with your template, besides layout changes, you need to get familiar with Magento’s objects (classes).

Let’s have a look at the /app/design/frontend/default/default/template/catalog/product/view.phtml file. If you open this file and execute var_dump($this) your browser will return empty page after a short period of delay. By page I mean on the product view page; the one you see when you click on Magetno product. Experienced users will open PHP error log and notice the error message caused by var_dump(). Read more

5