Hi,

   I needed to generate contents (like a sidebar, a custom footer) in the
default layout (layout.ctp) outside $content_for_layout from the views.

   I just made a simple helper to solve this:



> <?php
> class BlockHelper extends Helper
> {
>    var $prefix = 'dataBlock';
>    function setValue( $key = '', $value = 'value' ) {
>   $view =& ClassRegistry::getObject('view');
>   $view->viewVars[$this->prefix][$key] = $value  ;
>
>  }
>  function getValue( $key = '' , $defaulValue = '' ) {
>    $view =& ClassRegistry::getObject('view');
>     if  ( isset( $view->viewVars[$this->prefix][$key] ) ) {
>     return $view->viewVars[$this->prefix][$key]  ;
>    } else {
>     return  $defaultValue ;
>    }
>    }
> }
> ?>


In the layout I use:



> echo $block->getValue( 'sidebar' ) ;
>


and in the views:


 // inside view posts/view


> $block->setValue ( 'sidebar', 'There isn't comments' );
>

// inside view contents/view


> $block->setValue ( 'sidebar', $this->requestAction('/contents/menu/1',
> array('return'))  );
>

[...]

I don't know if it is the best way to solve it. ¿ Any ideas ?





-- 

    Antonio Cortés (Dr Zippie)

"El ordenador es la evolucion logica del hombre: Inteligencia sin moral":
John Osborne.
"A nullo videbatur, ipse autem omnia videbat"

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to