I want to pass a value from default.ctp to a view and I trie开发者_如何学God just assigning a php variable as well as
$this->set('myvariable','value');
but with no success.
Views are rendered first and then embedded into the layout. You can pass variables from views to the layout, but not the other way around.
As the other answer has stated, the view is rendered before the layout, meaning that you can't pass information in that direction. Whatever information it is that you want to pass to default.ctp will need to come from a controller. If you're reluctant to do that because it is shared between multiple controllers, you might want to consider putting it in a component, or alternatively inside your application's app_controller.php in the beforeFilter method, so that it is always available for default.ctp.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论