![]() |
View cell controllers in a folder - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: View cell controllers in a folder (/showthread.php?tid=77341) |
View cell controllers in a folder - legon614 - 08-19-2020 Hi, I started using view cells, which is really nice. I have the logic in App\Controllers and it works like a charm. Now I want to move them to App\Controllers\ViewCells folder, but I get an error. "Unable to locate view cell class: \App\Controllers\ViewCells\DialogSound." Any idea on how to solve this? Controllers seems to be the place for them since they inherit the basecontroller as well. They need some data. RE: View cell controllers in a folder - jreklund - 08-19-2020 Hi, you need to show us some code, on how you try to load it. And information on how you named them. As case sensitivity are importent. RE: View cell controllers in a folder - InsiteFX - 08-20-2020 Did you change the namespace when you moved them? RE: View cell controllers in a folder - legon614 - 08-20-2020 (08-19-2020, 01:00 PM)jreklund Wrote: Hi, you need to show us some code, on how you try to load it. And information on how you named them. As case sensitivity are importent. From the view: PHP Code: <?= view_cell('\App\Controllers\ViewCells\DialogSound::index') ?> app/Controllers/ViewCells/DialogSound.php (controller): PHP Code: namespace App\Controllers; I tried changing the namespace to App\Controllers\ViewCells but then it wasn't the same as the BaseController. RE: View cell controllers in a folder - legon614 - 08-20-2020 (08-20-2020, 03:08 AM)InsiteFX Wrote: Did you change the namespace when you moved them? I tried... with App\Controllers\ViewCells - the same as the folder structure. But it extends BaseController which uses App\Controllers. My PHP knowledge is not good enough to figure this one out ![]() RE: View cell controllers in a folder - jreklund - 08-20-2020 Hi, this should do the trick. PHP Code: namespace App\Controllers\ViewCells; or PHP Code: namespace App\Controllers\ViewCells; RE: View cell controllers in a folder - legon614 - 08-20-2020 (08-20-2020, 08:39 AM)jreklund Wrote: Hi, this should do the trick. OMG it did! You are a legend! Thank you very much ![]() While you are here.... do you know if it's bad for performance to have 3-6 of these view cells on a single page? I have a template and I rather not have all data put into it. It becomes a mess quickly. RE: View cell controllers in a folder - jreklund - 08-20-2020 Your welcome, namespacing itself are quite old, but I just learned it two years ago. And now I can't go back... No, that's a rather small number, as I would do that for all my widgets. But remember to utilize some sort of cache, either in the view cell themselves or cache the entire page. RE: View cell controllers in a folder - Corsari - 04-16-2023 (08-20-2020, 11:03 PM)jreklund Wrote: Your welcome, namespacing itself are quite old, but I just learned it two years ago. And now I can't go back... How do you enable such cacheing? Is it on page? Or... ? Thank you |