views:

21

answers:

2

is there a reasonable way to access the view attribute "passedArgs" (or any similar)

/* view */
$this->passedArgs

from within a Helper?

I'd be happy to customize the _construct() of the helper or to customize the app_helper... but I don't want to have to pass $this->passedArgs into the helper on every view or usage.

A: 

Have you tried just setting the view's value from the AppController?

class AppController extends Controller {
 function beforeFilter() {
  // other stuff
  $this->set( 'passed_args', $this->params['pass'] );
 }
}
Travis Leleu
+1  A: 

If you grab the current view object from within the helper you should be able to get to its passedArgs.

class SomeHelper extends AppHelper {
  function __construct($settings = array()){
    $this->passedArgs = ClassRegistry::getObject('view')->passedArgs;
  }
}

That should get you what you want.

Enjoy, Nick

Nick