cakephp: use view blocks generated by cell within main layout/vew/request
This is a (multiple allowed):
-
bug
-
enhancement
-
feature-discussion (RFC)
-
CakePHP Version: 3.4.x
What you did
A way to render blocks(like js making with scriptBlock() ) within main layout
//cell
$this->Html->scriptBlock('alert("hi")', ['block' => 'blockName']);
//layout : outside of cell
$this->fetch('blockName');
I can explain more with sample if you need
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 3
- Comments: 32 (28 by maintainers)
You could also pass the current view into the cell as an argument. You’d then be able to use the ‘parent’ view’s helpers. Something like:
I’m not convinced that we should break the encapsulation/isolation when there are existing solutions.
Oh I figured it out! You can do it without any changes. We just need to document this better.
An example
index.ctpusing a cell:I think the above would solve the problem. We need some way of making this easy for people to do.
I was thinking we could add a ‘cache’ parameter to the options array when calling
View::cellbut the problem there is that the cell method returns an object.I’ll think on this for a bit.
This needs to be fixed without introducing special new methods that a developer needs to know about. Otherwise, it will be impossible for plugin developers to use the script block from inside their plugin’s cells.
if js vars/Html created by model data( DB/… ) we need access 2 time to DB(for example) I know we can using cache But … is not fast way for developing 😃
and using of 2 cells is not clear
I agree with you but for some usage we need for that , like when using
scriptBlock()within Cell and we need render it after other js in mail view element cannot support total of usages, because we need access to model (for example)I think he wants to share view blocks between cells and the main view rendering process.