ZF-2737: Zend_View_Helper_PartialLoop loop counter

Description

I think it will be nice to have a counter in PartialLoop, in order to perform certain operations.

For instance: 1. To create a zebra striped table 2. To present an ordered list not using "ol" tags.

Any toughts?

Comments

Scheduling for mini release following 1.5.0 final release

This issue should have been fixed for the 1.5 release.

Please categorize/fix as needed.

To add A simple partialCounter variable:

Added to Zend_View_Helper_Partial on line 75 below $view = $this->cloneView();

    if ( isset($this->partialCounter) ) {
        $view->partialCounter = $this->partialCounter;
    }

Added to Zend_View_Helper_Partialloop:

public $partialCounter = 0;

And Changed the foreach loop in Zend_View_Helper_Partialloop on line 68 to foreach ($model as $item) { $this->partialCounter++;

        $content .= $this->partial($name, $module, $item);
    }

To add A simple partialCounter variable:

Added to Zend_View_Helper_Partial on line 75 below $view = $this->cloneView();


        if ( isset($this->partialCounter) ) {
            $view->partialCounter = $this->partialCounter;
        }

Added to Zend_View_Helper_Partialloop:


        public $partialCounter = 0;

And Changed the foreach loop in Zend_View_Helper_Partialloop on line 68 to:


        public $partialCounter = 0;

        foreach ($model as $item) {
            $this->partialCounter++;

            $content .= $this->partial($name, $module, $item);
        }

This doesn't appear to have been fixed in 1.5.0. Please update if this is not correct.

Updating project management info.

While adding the counter, it would be useful to add a total variable too. Then it will be possible to determine if it is the last index or not.

This should be a must for the release.

e.g. if you need/require zebra striped tables/lists you can't use this.

There could be a default class value

e.g. echo $this->loopClass (or equivalent $this->loopDefaultClass etc.) which would return "odd" or "even" depending on loop count as default.

In your list/table then instead of

you could have simply Don't know if this is too much to ask, but at least the loop count should be a must for the next release.

This has been added in with r12577

@Jon Whitcraft: the short way to say: thank you! :)

Changing issues in preparation for the 1.7.0 release.

I have some issues with the way that this has been implemented, the partial class is being used to set parameters in the view that are created in the partialLoop extension of the class. I have a working copy of my own version of partialLoop that does not require changes to partial to make it work.

Bittarman has kindly offered to mentor me next week so that I can figure out how to get my proposed changes into the system for review.

Just wanted to make a note of my intentions incase anyone here already has some other ideas - and so I don't forget, or get lazy and not do it ;-)