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.
Coming from #1147048: AdvAgg, LABjs, CTools - JS Settings Issues
I'll be working on a patch for CTools to make this work with AdvAgg's various hooks. If it doesn't do what we need it to out of the box then I will adjust advagg accordingly to make it happen.
Comment | File | Size | Author |
---|---|---|---|
#9 | ctools-advagg-1149792-9.patch | 4.6 KB | mikeytown2 |
#7 | ctools-advagg-1149792-7.patch | 4.58 KB | mikeytown2 |
#5 | ctools-advagg-MIN-1149792-5.patch | 1.17 KB | mikeytown2 |
#3 | ctools-advagg-BARE-MIN-1149792-3.patch | 873 bytes | mikeytown2 |
#3 | ctools-advagg-MIN-1149792-3.patch | 1.71 KB | mikeytown2 |
Comments
Comment #1
mikeytown2 CreditAttribution: mikeytown2 commentedAdjustments have been made to advagg.
Here is the patch for CTools.
hook_js_replacements is no longer used, and it doesn't write a script tag to the closure anymore. Will also grab JS files loaded in other places besides the header and footer.
Comment #2
merlinofchaos CreditAttribution: merlinofchaos commentedCan we do something a little bit smarter than this? Is there an advagg hook that runs prior to the page preprocess, for example, that I could just set a variable rather than doing a module_exists? It would be nicer if this were more generic since there could be other reasons to avoid ctools doing this and possibly other modules could set that.
Comment #3
mikeytown2 CreditAttribution: mikeytown2 commentedadvagg uses a hook_init. I'm thinking we could have a variable called "ctools_ajax_page_preprocess". In advagg_init I can set
$conf['ctools_ajax_page_preprocess'] = FALSE;
.The variable check is the bare minimum needed to get this working (i would have to re-implement ctools_process_js_files). It would be nice if ctools_process_js_files() took $scripts as the input rather than $scope; similar to ctools_process_css_files(). Placing advagg hooks in ctools would be nice, but I can implement those hooks in advagg; have them run if CTOOLS_AJAX_INCLUDED is defined.
Here are 3 patches; the bare minimum, minimum and a patch that uses advagg hooks in ctools.
Comment #4
merlinofchaos CreditAttribution: merlinofchaos commentedI think I prefer the min but I will listen to discussion about whether CTools should support AdvAgg or the reverse. Obviously my typical stance is that I try to push support out, but AdvAgg ties so closely to this that I can see supporting it in CTools.
That said, variable_get() is probably bad -- since variable_set() will cause a cache write every time it's called. A ctools_static() is probably a better choice than a variable_set() since the latter also persists and I'd rather do this on a per page load basis.
I totally don't mind modifying ctools_process_js_files but I'm curious if $contrib is using it. I would be more comfortable if we changed it in such a way as to not break the function signature, by adding an extra $scripts = NULL argument
That is the least invasive change and wont' cause someone ELSE using this to break.
Comment #5
mikeytown2 CreditAttribution: mikeytown2 commentedGood call with ctools_process_js_files. The way I was going to use variable_get didn't involve variable_set; but that might not be true for someone else. Here is the min patch again with your changes.
As for advagg hooks, if you want to dive in deep and use the $conf['advagg_css_render_function'] & $conf['advagg_js_render_function'] to have aggregates used in ctools_ajax_render instead of loading each file, that can be done; but it would require you to send the CSS & JS files that are already loaded back in the ajax request. What you have works well, just bringing this up as it gives a theme option for the CSS & JS files, something that could be useful for ajax. The other thing that could be useful is allowing anonymous functions or function callbacks in the js settings http://drupal.org/node/1148204#comment-4437152.
Comment #6
merlinofchaos CreditAttribution: merlinofchaos commentedI think we're almost done.
Let's add a function that sets the static so that we can document what the static does and why one would use it easily. How about...ctools_skip_js_aggregation($value = FALSE);
Comment #7
mikeytown2 CreditAttribution: mikeytown2 commentedAdded documentation to the functions this patch touches and fixed some spelling errors in the documentation.
New function is called ctools_ajax_run_page_preprocess()
Comment #8
merlinofchaos CreditAttribution: merlinofchaos commentedThey can't both use __FUNCTION__ -- that makes them separate variables.
Comment #9
mikeytown2 CreditAttribution: mikeytown2 commentedgood eye
Comment #10
mikeytown2 CreditAttribution: mikeytown2 commentedComment #11
mikeytown2 CreditAttribution: mikeytown2 commentedIn regards to closer advagg integration; You don't have to send back every CSS/JS file loaded in the aggregate for ctools_ajax_render(). Just need to send back the aggregated MD5 value and CSS/JS files that are outside of the aggregate; advagg keeps a record of what files are in the aggregate so you can look up the md5 and figure out what files where loaded on the page.
JS code for pulling CSS and JS files loaded on the page.
Comment #12
mikeytown2 CreditAttribution: mikeytown2 commentedan idea when the patch in #9 will hit? The other comments are ideas, #9 is code that would be nice to have in ctools. If this is not going to be committed let me know; I have other hack-ier ways to work around this.
Comment #13
merlinofchaos CreditAttribution: merlinofchaos commentedSorry, have been stuck with client work and haven't had much free times for the issue queues the last 2 weeks.
Comment #14
Peter Bowey CreditAttribution: Peter Bowey commented#9 patch works for me with ctools + advagg
Thanks Mike!
Comment #15
naeluh CreditAttribution: naeluh commented2 questions -
- Is this only for 6.x-1.x-dev or can this be used with the stable release of ctools
- Is this for panels 2 or 3 or does that not matter '
Cause I applied the patch on #9 and I am still returning the same problems with ajax
I am running panels 2 and ctools 6.x-1.8
thanks!
Comment #16
mikeytown2 CreditAttribution: mikeytown2 commented@naeluh
What are your ajax problems?
Comment #17
naeluh CreditAttribution: naeluh commented@mikeytown2
weird now its working I think I just needed to clear the cache or something, I will let you know if I experience any thing out of the ordinary thanks!
#9 worked for me!
Comment #18
jthomasbailey CreditAttribution: jthomasbailey commentedTrying it out because I was having trouble with advagg and ajax flags, it helps a little but it isn't perfect. The throbber and the "you flagged this!" text doesn't show up and flagging occasionally doesn't work, haven't figured out what breaks it yet.
Comment #19
jthomasbailey CreditAttribution: jthomasbailey commentedNevermind, I think my problem has to do with the Highslide modal I'm opening the flags up in.
Comment #20
crea CreditAttribution: crea commentedI have an issue with
ctools_ajax_render()
. Together with AdvAgg it outputs unprocessed system.css which breaks the theme after an ajax request.Should this patch cover that too, Mike ? The patch doesn't fix the issue with CTools dev snapshot from 2010-10-16.
Comment #21
mikeytown2 CreditAttribution: mikeytown2 commented@crea
Can you give more details of what happened VS what you expected to happen? What do you mean by "unprocessed"?
Comment #22
crea CreditAttribution: crea commented@mikeytown2
After ajax request unprocessed (I mean non-aggregated) system.css styles override aggregated css styles, so design breaks (a little). Ofcourse I expect design not to break with ajax. Looks like system.css styles should be already inside the aggregated files.
You can test it with my Devel Query Ajax module which uses CTools.
Comment #23
jcisio CreditAttribution: jcisio commentedI've just updated ctools and this patch still works flawlessly.
Comment #24
soulfroysThe patch in #9 solve my problem:
With Advagg (6.x-1.9) + Vote Up/Down (6.x-3.2), after voting, the layout breaks in a horrible way...
Thanks!
Comment #25
japerryLooks good, fixed!