After digging around in all the classes that referred and such I found no
use of the stored variables (_container) from the layout.php file..

So, I modified the render function in layout.php for a quick and dirty
test..

...
        $view = $this->getView();

        // quick and dirty assign stored vars to view
        foreach ($this->_container as $k => $v) {
                $view->$k = $v;
      } 
...

This passes the variables stored in the _container, from assign and _set
function, in to the layout's view ... 

The variables did get assigned to the layout view and the page returned no
errors.

I'll leave this patch my code so that I can continue programming on my
project ...

Any thoughts on this problem ?

Terre

-----Original Message-----
From: Terre Porter [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 06, 2008 12:12 PM
To: fw-general@lists.zend.com
Subject: [fw-general] Layout assign function...

Hello,
 
I've got myself a bit confused, maybe someone can clarify this for me.

Some background:

I've got variables in my actions that I would like to pass to my layout. 

Currently I'm doing this ...

In my actionController, ---> $this->view->noContentBorder = true;

In the view template for that action, --->
$this->placeholder('noContentBorder')->set($this->noContentBorder);

And then in the layout it's something like, --> if
(isset($this->noContentBorder) && $this->noContentBorder == true) {...

Ok, so I'm wanting to remove the place holder because there are a few views
that have only placeholders for forwarding them to the layout template.

I tried this in the actionController, -->
Zend_Layout::getMvcInstance()->assign('noContentBorder',true);

However, it doesn't seem to work ...

I looked at the assign function in the layout, simply put it assigned the
variable to an array...
-- $this->_container[$spec] = $value;

In the render function, the comments say - * assigns layout variables to
view,...

But, I do not see where the variables from the $this->_container are
assigned to the layout view that is rendered ... 

What am I missing ...

Terre

~ snip render function from zend/layout.php

/**
     * Render layout
     *
     * Sets internal script path as last path on script path stack, assigns 
     * layout variables to view, determines layout name using inflector, and

     * renders layout view script.
     *
     * $name will be passed to the inflector as the key 'script'.
     * 
     * @param  mixed $name 
     * @return mixed
     */ 
    public function render($name = null) 
    { 
        if (null === $name) {
            $name = $this->getLayout();
        }

        if ($this->inflectorEnabled() && (null !== ($inflector =
$this->getInflector())))
        {
            $name = $this->_inflector->filter(array('script' => $name));
        }

        $view = $this->getView();

        if (null !== ($path = $this->getViewScriptPath())) {
            if (method_exists($view, 'addScriptPath')) {
                $view->addScriptPath($path);
            } else {
                $view->setScriptPath($path);
            }
        } elseif (null !== ($path = $this->getViewBasePath())) {
            $view->addBasePath($path, $this->_viewBasePrefix);
        }

        return $view->render($name);
    }




Reply via email to