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.
#attached supports external files, because drupal_add_js/css does.
But because drupal_process_attached mucks around quite a bit with the parameters it passes to the above functions it's not really trivial to see how it's done.
At least it took me about 2 hours and a nudge from sun...
Here's a patch that adds a bit of documentation including a code example.
Comment | File | Size | Author |
---|---|---|---|
#15 | 880368-15.patch | 698 bytes | jhodgdon |
#11 | 880368-11.patch | 764 bytes | tstoeckler |
#9 | 880368-9.patch | 1.06 KB | tstoeckler |
#4 | documentation_drupal_process_attached_external_2.patch | 1.17 KB | tstoeckler |
documentation_drupal_process_attached_external.patch | 837 bytes | tstoeckler | |
Comments
Comment #1
moshe weitzman CreditAttribution: moshe weitzman commentedthx
Comment #2
Dries CreditAttribution: Dries commentedI sounds like the verb 'be' is missing between 'also' and 'loaded'. The syntax is awkward but we'll work on that later.
Comment #3
jhodgdonThere also shouldn't normally be a blank line before the @code, since it's logically part of the same paragraph.
Comment #4
tstoecklerHere you go. There was a newline before @code right above that so I removed that as well.
Comment #5
tstoecklerSetting to 'Needs review'.
Comment #6
sunSince this is in the docs for #attached, we don't need to repeat "using the #attached syntax". Lastly, we can shorten the remaining:
"External files can also be loaded, but is restricted to the 'js' and 'css' types. For example:"
That said, I find it very odd that url() detects external URLs and automatically handles them accordingly, but drupal_add_js/css() do not?
Powered by Dreditor.
Comment #7
tstoeckler"External files can also be loaded, but is restricted to the 'js' and 'css' types. For example:" <- Sorry, but I'm pretty certain that's not correct English =)
Comment #8
jhodgdonstatus change as per #6. Note in #7 - is->are
Comment #9
tstoecklerRerolled.
Comment #10
jhodgdon"but only the 'jss' and 'css' types. "
Should be 'js' not 'jss'
Also this patch is missing the drop-the-newline bit from the previous patch.
Comment #11
tstoecklerThe stray newline must have gotten lost in another commit. Anyway rerolled for 'jss' => 'js'.
Comment #12
jhodgdonThis looks OK to me. I'll let someone else who commented above set to RTBC though.
Comment #13
sun"but only the 'js' and 'css' types" works on its own, but as part of the full sentence, it reads somewhat incomplete.
Shouldn't that be "External files can also be loaded, but only FOR the ... types" ?
Overall, how about:
"External files can be loaded for type 'js' and 'css'. For example:"
Powered by Dreditor.
Comment #14
jhodgdononly FOR the types?
Actually, that sounds worse to me.
How about: External CSS and JavaScript files can also be loaded. For example:
Comment #15
jhodgdonHere's a new patch. There was also a missing ' in the code example...
Comment #16
tstoecklerGreat!
Comment #17
webchickCommitted to HEAD. Thanks!