Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I think it would be the beez kneez to ship ctools with a sample module that shows how to use the AWESOME POWER of the ajax and modal functionalities. I saw Roger present this in NYC, and wrote such a module on the plane to NOLA. I'm open to suggestions of other things we should show off how to do, but here's a first attempt.
This could also be merged with the existing sample module rather than starting as it's own.
Comment | File | Size | Author |
---|---|---|---|
ctools_ajax_sample.tgz | 1.83 KB | joshk |
Comments
Comment #1
corbacho CreditAttribution: corbacho commentedThanks for this piece of code Josh!
It helped me to prepare my own demo modules to the session of Drupal camp.
I discovered a little bug in your code that was difficult to track, but I found finally the reason:
This is a piece of code from ctools.module file:
It makes that the argument that you pass to the callback function converts to TRUE or 0
In your code you have:
When should be directly if ($js). yeah! that easy
That condition is stopping your code from working when javascript disabled.
This conversion of "ajax" to TRUE only happens if you use in the hook menu the argument %ctools_js
If you use any other name, it will not happen.
So I avoided to use %ctools_js to do it more "cross-drupal-compatible", because it seems Drupal 7 AJAX framework won't have these conversions.
Here the slides and demo code I prepared, hope it helps someone:
http://www.drupro.com/blog/david-corbacho/drupal-ajax-new-way
Comment #2
merlinofchaos CreditAttribution: merlinofchaos commentedCleaned up, added to, and committed.