Accessing from controller is done via $this->getInvokeArg(), if you
use FC parameter.

You may want to look at why you want to have config, cache and locale
access in your view, generally this would happen in the Model or
controller.

If you do need to do this I would suggest using a view helper, this
way you encapsulate the access away from the main view scripts.

class Zend_View_Helper_MyViewHelper
{
    public function MyViewHelper ()
    {
        $fc = Zend_Controller_Front::getInstance();
        $fc->getParam('xxx');

        // or
        $config = Zend_Registry::get('Zend_Config')
    }
}

There are of course many ways to do push stuff into views, in your
bootstrap you can set variables on the view, and you can use front
controller plugin, action helpers etc.

Just have a think to why you need to do this, it may be that this
should be handled in your Model.

Thx

Keith

2009/4/8 Elvin Şiriyev <el...@siriyev.net>:
> 2. way sounds good. but how can i access frontController's params from
> controller and view script ?
> i dont like write that codes for each Action
> ----------------------------------
> $config = Zend_Registry::get('Zend_Config');
> $cache = Zend_Registry::get('Zend_Cache');
> $locale = Zend_Registry::get('Zend_Locale');
> ..
> .
> $this->view->config  = $config;
> $this->view->cache = $cache;
> $this->view->locale = $locale;
> ..
> .
> ---------------------------------
> 2009/4/8 keith Pope <mute.p...@googlemail.com>
>>
>> Maybe use the registry for that, so have a bootstrap class resource
>> that fetches the plugin resources:
>>
>> protected _initRegistry()
>> {
>>    $this->bootstrap('db');
>>    Zend_Registry::set('dbResource', $this->getPluginResource('db'));
>> }
>>
>> Or you could pass them as params to the front controller, which would
>> make them accessible inside controllers:
>>
>> protected _initFrontControllerExtras()
>> {
>>    $this->bootstrap('frontcontroller');
>>    $this->frontController->setParam('x','xxx');
>>    // or
>>
>>  $this->getPluginResource('frontController')->getFrontController()->setParam('x','xxx');
>> }
>>
>> Hope this helps
>>
>> Keith
>>
>> 2009/4/8 Elvin Şiriyev <el...@siriyev.net>:
>> > hi, i used Zend_Application with Zend_Application_Resource_*.
>> > how can i access to that objects from my Controller and view?
>> >
>> > for example is there any way to access Zend_Application_Resource_
>> > Navigation 's  getContainer() method from controller like
>> > $this->navigation->getContainer() or $this->db, $this->layout,
>> > $this->locale
>> > or another easy way ?
>> >
>> > thanks
>> >
>> > --
>> > Elvin Şiriyev
>> > http://elvin.siriyev.net
>> >
>> > --
>> > Elvin Şiriyev
>> > http://elvin.siriyev.net
>> >
>>
>>
>>
>> --
>> ----------------------------------------------------------------------
>> [MuTe]
>> ----------------------------------------------------------------------
>
>
>
> --
> Elvin Şiriyev
> http://elvin.siriyev.net
>



-- 
----------------------------------------------------------------------
[MuTe]
----------------------------------------------------------------------

Reply via email to