Hi,
I have two layouts:
Layout.Main.cfm (default)
Layout.Admin.cfm
FYI: I am not using module for Admin section
Now I have all the views for admin inside the views/Admin directory
I want to use Admin layout for each view inside the admin folder.
Is it possible?
I tried to set the coldbox configuration like this:
layouts = [
{ name=“admin”,file=“Layout.Admin.cfm”,folders="^admin" }
];
But that not worked.
It uses only main layout.
Please help. I don’t want to specify layout in handler or action.
The best option is do a preHandler, prevent or preprocess for your handler that will use setLayout()
Thanks.
This is working.
I see this docs, so I thought my method may work. But it didn’t.
Well I didn’t know you could do it there as well, might need to check with Luis then because that should work. Maybe it doesn’t work because it might need to be ^handlers.admin as the folder by default is handlers then admin. But having said that is Admin a folder?
That should work actually.
As you suggested, I tried “^handlers.admin” and “^views.admin”. but no success.
All admin handlers are in handlers\admin directory
All admin views are in views\admin
layouts are in same directory: layouts\Layout.Admin.cfm and layouts\Layout.Main.cfm
Yeah I am not sure, I know that it probably uses a regex and that is something I will admit to being my absolute weakness. So maybe Luis or someone else can chime in with that setting, but I have always done the other way as I first suggested.
i've used the following in the past...
admin = {
file = "layout.admin.cfm",
folders = "admin"
}
with all my admin views being in the /views/admin directory and it has
worked for me.
Cheers
Frank
How do you write this setting in Coldbox.cfc?
I tried to write like:
layouts = [
{ name=“admin”,file=“Layout.Admin.cfm”,folders=“admin” }
];
But this does not work.
something like this should work.
layouts = {
admin = {
file = "layout.admin.cfm",
folders = "admin"
}
};
I am surprised that this is still not working for me.
Here we are creating a layout and giving them a name called “admin”.
Should I have to use it anywhere or not?
I just setup a little test to make sure, but this works
layouts = [
{ name = “admin”,
file = “Layout.Admin.cfm”,
folders = “Admin”
}
];
Then any view that I consume from the admin folder uses the admin layout, for example.
function index(event,rc,prc) {
event.setView(“admin/home”);
}
I even double checked and it worked fine with implicit views as well.
Thanks,
Curt
Thank you for your detailed answer.
I was appending extra “/” in view name and that cause the issue.
event.setView("/admin/home");