Skip to content

Instantly share code, notes, and snippets.

@robzienert
Created January 7, 2010 20:50
Show Gist options
  • Save robzienert/271556 to your computer and use it in GitHub Desktop.
Save robzienert/271556 to your computer and use it in GitHub Desktop.
class Prpl_View_Helper_Zebra extends Zend_View_Helper_Abstract
{
/**
* Internal tracker; static to allow tracking in partial loops, etc
*
* @var integer
*/
private static $_count = 0;
/**
* Alternate string
*
* @var string
*/
private static $_alternate = 'stripe';
/**
* Zebra cycler; similar to Zend_View_Helper_Cycle, but more to the point
*
* @param boolean $includeHtml
* @return string
*/
public function zebra($includeHtml = true)
{
++self::$_count;
$string = $this->getAlternate();
if ($includeHtml) {
$string = " class=\"{$string}\"";
}
return (self::$_count % 2) ? $string : '';
}
/**
* Set the alternate string
*
* @param string $alternate
* @return Prpl_View_Helper_Zebra
*/
public function setAlternate($alternate)
{
self::$_alternate = (string) $alternate;
return $this;
}
/**
* Get the alternate string
*
* @return string
*/
public function getAlternate()
{
return self::$_alternate;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment