Implementing Block Ajax in 5.7
...but I thought it warranted its own topic, so I'm starting this thread. (I don't know if this should be a github issue or not, as it might simply be something I don't understand about working with AJAX requests in 5.7.)
Anyway, my question has to do with AJAX requests within packaged blocks. Is there a convention to be followed when defining routes? They're easy enough to define with the new routing system, but it seems to me there's the potential for route collisions between different packages. (Actually, it would be more of a co-opting, as the last registered route would take precedence.)
While the old tools file approach is still supported, it's officially deprecated, so I'd like to use the new approach for future development efforts. Besides that, the tools file approach seems broken for non-core blocks.
Anyone have any input or insights?
Just reading through some 5.7-related forum threads, so I haven't actually worked with any of this yet. But if you're concerned about route collisions between packages, it seems to me that the safest bet would be to create a route that mimics the old /tools/ structure. For example, the route could be /packages/your_pkg_handle/tools/your_route
Or for that matter, any route with your package handle in it should be "unique" enough to avoid collisions.
Just a thought off the top of my head.
This isn't 100% set in stone but it's getting there. I'd be interested in your thoughts on directory naming, how the routes are automatically determined to be a part of the likes this package, the Router::route() method (inspired by JohnTheFish) and the URL::route() method. These methods automatically generate route names based on packages. We should also use them in the routes.php file in the core (haven't got around to doing that yet.)
Let me know what you think
Yeah I like having /views and /controllers. But for larger packages that can start to get pretty messy.
For example, ProEvents has dozens of different ajax views for just the list block.
I realize we all can do it really however we want with routes...but it would be great to document and standardize this in my mind.
To me, having purposeful readable folder structure by nature seems appropriate. So /packages/proevents/controllers/blocks/proevents_list/controllername.php paired with /packages/proevents/views/blocks/proevents_list/viewname.php
But we already have a /block folder for that context...so to me it makes more sense to keep things in that context. Otherwise you have /block in various places when there technically is no need:
Chicken or the egg perhaps. I am in favor of keeping it clean. And sense we already have to have a /block folder for each block by virtue of the app design, might as well keep things tidy imho.
How is either case overridden? User X wants to override an AJAX view?
Can you remove this attachment and/or replace it by the new one (2.0.1 on the marketplace) to avoid confusion.
Also, on the 2.0.1 version currently in the marketplace, you lefft 3 .DS_Store files.
Here again, as a PRB member (and admin :/) I would like you guys to clean the archive to give the future addons dev the right example :)
(Another side note, in your block view.php, you use Loader::helper, but I thought this was supposed to be deprecated in favor to Core::make right?)
I am actually looking to find / buy Block by Ajax for c5.7.
Are you aware of anything available or under development?
Thank you in advace
something on my immediate To-Do list.
I don't know of anything similar in the 5.7 marketplace or under