Domanda

I wonder if there is a similar method already built-in in any of Zend Framework 1 view helpers?

<?
public function val(&$var, $default = '') {
// if $var is undefined, return $default, otherwise return $var
   return isset($var) ? $var : $default;
}
?>

and in View:

<? $this->val($myvar); ?>

I know I can create my own helper, just don't want to duplicate something that might have already been done and Zend API reference hangs all of my browsers Thanks.

È stato utile?

Soluzione

You can use the declareVars view helper to assign your defaults beforehand.

$this->view->declareVars(array("username"=>"Not Logged In");

If that's not what you want I think you are left with implementing your own, a pretty trivial task.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top