# |
May 18th 2021, 15:18 |
etibor |
if i place my menus to the elments insted of the layouts it can be work. the only issue is that i can not replace the default.ctp menu with admin_menu.ctp in the view |
# |
May 18th 2021, 15:14 |
ndm |
Yes. The only way to avoid that would be to create a custom command I think, one that scans for all tables, and runs the policy bake command for each table/entity. |
# |
May 18th 2021, 15:11 |
paolo.bragagni |
(all my policies) |
# |
May 18th 2021, 15:07 |
paolo.bragagni |
Si we have to edit all my actions manually?? |
# |
May 18th 2021, 15:02 |
ndm |
@paolo.bragagni That's not going to happen, what is baked by the `all` command is hardcoded in that command. |
# |
May 18th 2021, 15:01 |
ndm |
That doesn't answer my question though. |
# |
May 18th 2021, 15:00 |
etibor |
well the thing for the UsersController located in Templates/Users - without the prefix |
# |
May 18th 2021, 14:56 |
ndm |
@etibor Are you just using separate templates so that you can display different menus per role? |
# |
May 18th 2021, 14:47 |
paolo.bragagni |
it creates a LibroPolicy.php in my src\Policy |
# |
May 18th 2021, 14:46 |
paolo.bragagni |
I'd like that when I fire bin/cake bake all Libri -t BragBake |
# |
May 18th 2021, 14:44 |
paolo.bragagni |
bake template for policy? |
# |
May 18th 2021, 14:39 |
etibor |
the issue is when i navigate to the users/profile page and logged with admin for example i navigate to site-url/admin/users/profile |
# |
May 18th 2021, 14:37 |
etibor |
i have now: Template/admin/layout/admin_menu.ctp Template/clerk/layout/clerk_menu.ctp while my commonly used functions located in Controller/UsersController.php - non prefixed |
# |
May 18th 2021, 14:33 |
ndm |
Trying to substitute layouts is most likely having looots of pitfalls, I probably wouldn't even try it, rather I'd use a custom view or live with the mentioned layout subdirectory "workaround". |
# |
May 18th 2021, 14:30 |
etibor |
however when i tried to use element insted of layout it was only good for side menu, because the default top menu is the default layout |
# |
May 18th 2021, 14:29 |
etibor |
okey i now i a little more familiar with the concept |
# |
May 18th 2021, 14:24 |
ndm |
You could use subfolders in the default layout folder though? Sure, it's separate from the prefix template subfolders then, but still properly separated and in a place where it makes sense. |
# |
May 18th 2021, 14:22 |
ndm |
You can't just use that anywhere, it's tied to the view's internals. As you noticed, changing the layout path only changes where things point to inside of the default layout folder, more drastic changes can only be applied on view level. |
# |
May 18th 2021, 14:20 |
etibor |
i have just could not figured out how can i use that costumViews's functions |
# |
May 18th 2021, 14:19 |
etibor |
https://github.com/cakephp/cakephp/issues/3907 |
# |
May 18th 2021, 14:19 |
etibor |
the real issue is coming by the setLayyoutPath can not point out the prefixed layout directory path |
# |
May 18th 2021, 14:18 |
etibor |
my problem in short, i have different prefixes for different roles, i have non prefixed Controllers for commonly used function when i navigate to the non prefixed Controller, the page is look for the non prefixed layout directory, and con not change it by set Layout Path in my case layout are difinied two times, first in the prefixed layout directory, secondly by the non prefixed layout directory - this is simple not DRY |
# |
May 18th 2021, 14:02 |
ndm |
Why even in the first place? I don't really know what problem exactly that snippet there is trying to fix, but layouts for prefixes should work out of the box IIRC. |
# |
May 18th 2021, 13:59 |
etibor |
how can i use an element insted of a layout ? |
# |
May 18th 2021, 13:41 |
etibor |
this could solve my issue: https://gist.github.com/TamiasSibiricus/a1010fc95839f79e9e8a however i dont really knows how to use view's function in Controller |
# |
May 18th 2021, 13:40 |
etibor |
with layouts, i have a lot of issues, when i have multiple prefixes |
# |
May 18th 2021, 13:38 |
etibor |
its the first time that i try to work with elements, using insted of layouts |
# |
May 18th 2021, 13:37 |
etibor |
thank you @ndm |
# |
May 18th 2021, 13:32 |
ndm |
@etibor Use `disableAutoLayout()` instead. On 3.x you could also set the layout to `false` instead of an empty string, but that won't work in 4.x anymore. |
# |
May 18th 2021, 13:17 |
etibor |
using : $this->viewBuilder()->setLayout(''); will disable the rest of the template too not just the layout |
# |
May 18th 2021, 13:16 |
etibor |
hello how can i disable the default layout |
# |
May 18th 2021, 11:19 |
neon1024 |
Ah, it is still there. What an odd bug |
# |
May 18th 2021, 11:14 |
neon1024 |
Is the `Model.initialize` event not a thing any more? I can only see DebugKit calling it in my listener |
# |
May 18th 2021, 09:57 |
ndm |
Not necessarily, you can also do a find after using `saveAssociated()`, and then use the query model id for one last separate save that updates the order. |
# |
May 18th 2021, 09:50 |
rightscoreanalysis |
thanks @ndm - so the way to go would be to use seperate saves and then use $this->Model->Id to seed the foreign keys manually? |
# |
May 18th 2021, 09:39 |
ndm |
But even if it were generally possible, it would not be practical with a "to many" association, as the saving logic wouldn't which of the possibly many addresses should be associated with the order. |
# |
May 18th 2021, 09:37 |
ndm |
@rightscoreanalysis That's not possible no, only directly association models can be automatically decorated with a foreign key. |
# |
May 18th 2021, 09:32 |
rightscoreanalysis |
my question about saving back through a relationship better explained here, I am sure those most knowledgeable will know if what I am attempting is possible or not: https://stackoverflow.com/questions/67582761/cakephp-saving-fk-back-through-data-in-a-multiple-relation-structure |
# |
May 18th 2021, 09:21 |
neon1024 |
Thanks for the tips everyone :bow: |
# |
May 18th 2021, 09:21 |
slackebot |
I bet that will fill in my mental gaps :) |
# |
May 18th 2021, 09:21 |
neon1024 |
Oh right that does make sense. The main thing was that we have a custom RoleAuthorize class, which I wanted to keep. So I can refactor to Policies in another PR. The request middleware looked a good spot to just call an instance of that class and return it’s `authenticate()`. Which does seem to work, but now I know I need to massage it a bit :thumbsup: Although I’m going to read through the bits that @steinkel linked, as |