Zend View Helpers inheritance

development, php, plugin, zend No Comments »

It’s handy to use View Helpers in Zend FW driven project. For example, you want to make an in-place tracker (e.g. Google Analytics) — you create a helper class My_View_Helper_Tracker inherited from Zend_View_Helper, Zend finds its automatically and then you are free to use your helper method:

echo $this->tracker( $trackerID );

The question is what you gonna do if you want a base class for a family of trackers?

It’s not so obvoius due to naming conventions.

Let’s say you want 2 kinds of trackers: Google Analytics and Euroads.

1. You create such files structure:


library
 - My
   - View
    - Helper
      - Tracker
        Abstract.php
        - Google
          Page.php
        - Euroads
          Owner.php
          Guest.php

2. You name your classes as:

  • My_View_Helper_Tracker_Euroads_Guest (extends My_View_Helper_Tracker_Abstract)
  • … so on …

3. Class methods are:

public function tracker_euroads_guest(...) ...

4. And the trickiest part: the helper call:

echo $this->tracker_Euroads_Guest

jQuery plugin: Add2Cart

jquery, plugin 19 Comments »

I added a jQuery plugin called add2cart.

This plugin implements visual effect of adding something to cart (busket). Visually it’s similar to Microsoft Word post-save visual effect, when a gray rectangular of page moves down to the toolbar.

Example of usage:

<input type="button" value="Add to cart"
  onclick="$.add2cart( 'product1_id', 'cart_img_id'  )" />

You can try it out at demo page.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in