Routes are a great feature, but if you try using them with Plugins you might find that you start pulling your hair out. Fear not however, there's always a solution and it's usually not that difficult. If you use routes of the form below, you can map directly to a plugin's page:
[Code]Easy when you know how.
One word of warning though, the first parameter in this route has a default which is the controller action. This means that if you create route which expect parameters (as I did in the example) it will work with no parameters, but if any parameters are passed the first one will be understood to be the method name.
Quite often the question is asked "How can I access XYZ in my controller/view/model etc?". IMO this question rarely needs to be asked ;).
Using the following simple approach should empower you to answer most questions:
- Set DEBUG to 2 in your /app/config/core.php file so you can see the executed SQL whilst you are developing, you can set it to 3 to see a dump of the current controller at the foot of the page (might make your page loads a bit cumbersome - especially if you have ajax requests).
- Use the Search facility, pay particular attention to the API.
- Don't be afraid to look at the cake source code; you may be able to quickly see the answer to your question. DON'T make changes to the code (except perhaps temporary debug code) or you may find that upgrading becomes a 2hour task instead of a 2minute one.
- If in doubt stick something like this in your code: [Code]
- Don't forget that CakePHP is still PHP :); If you know some data has been set somewhere but you don't know where it is - use what PHP provides such as Get defined vars and search the output on your screen.
If you still don't know where something is after that - think if what you are trying to do is logical, and if you think that it is, it might be worth asking.
The singer Beyonce
If you use MPTT tables anywhere (The cake acl system uses it) you may have found that when you delete an entry, the lft and rght fields for the neighouring nodes don't get updated. This may have rather dire concequences ;)
There is an open ticket for how to delete from the cake acl tables, but as it is potentially quite generic, I thought I'd include the (potential) fix here. Below are two versions of a delete method, one takes care of associations, and the other doesn't:
[Code]Should anybody use this and find it causes a problem please let me know.
A long time ago, I took to using elements as shown in the paste below.
[Code]I hope the time I spent trying to figure this out is saved for others :)










