开发者

Setting Layout Variables from the View

开发者 https://www.devze.com 2023-03-16 15:59 出处:网络
I\'m working on a CakePHP website and I have a split view (two divs next to each other). The first div will display all my content i.e. articles, with tags and pagination etc, but the other one (the s

I'm working on a CakePHP website and I have a split view (two divs next to each other). The first div will display all my content i.e. articles, with tags and pagination etc, but the other one (the sidebar) will have site wide stuff like Twitter and Facebook links as well as 'most pop开发者_StackOverflow社区ular tags' etc.

On some of the administrative pages (crud) I want to place the Actions div into the sidebar. However, these links are defined in the view. Is there a way I could save this information into a variable and call that variable in the layout file - similar to $content_for_layout?


Yes. Just save them as a variable and echo it out in the Layout. Basically a layout is just another view, so I would think you should be able to just cut the "Actions" out of the view, and paste it in the proper place in the Layout your talking about... this should keep the Cake part working the proper way.

Update: I just thought about a slight problem... with what I wrote above. You should be able to just paste the actions into the array, but if the controller that your using is missing some of the variables being used in the actions then cake will throw an error.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号