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.
How to disable 1.7 version on admin and node/add pages?
i.e.
If page = node/add/node-type or admin/ = jquery_update with 1.3
Comment | File | Size | Author |
---|---|---|---|
#56 | jquery-version-alter-1539276-56.patch | 1.28 KB | sokru |
#51 | jquery_update-disable-jquery-update-on-specific-paths-1539276-51.patch | 818 bytes | samuel.seide |
Comments
Comment #1
Stan.Ezersky CreditAttribution: Stan.Ezersky commentedMy solutuion
Comment #2
rokr CreditAttribution: rokr commentedIs this related? #1524944: Allow different version for administrative pages
Comment #3
markisatacomputer CreditAttribution: markisatacomputer commentedI needed functionality like this so I ended up adding another setting so that certain paths will be excluded entirely from update.
Here's a patch.
Comment #4
markisatacomputer CreditAttribution: markisatacomputer commentedok. That was a little hasty. I decided to throw in the classic choice between either excluding a set of paths or only including that set. Here's the updated patch.
Comment #5
kpa CreditAttribution: kpa commentedAlthough #2 is related, #4 gives the eventual result in a much simpler way.
Excellent patch @markisatacomputer - +1 to get this into dev version of jquery update.
Comment #6
pitxels CreditAttribution: pitxels commented#4 Perfect, I really think this is how this module should be for 6.x
Comment #7
Stan.Ezersky CreditAttribution: Stan.Ezersky commented$4 great!
Comment #8
Michsk CreditAttribution: Michsk commentedHere's the patch for D7, totally based on #4
Comment #9
tempo22 CreditAttribution: tempo22 commenteddon't forget to change the path
--- L:/LASAC/DEV/SITES/sites/indepressie.localhost/
Comment #10
serjas CreditAttribution: serjas commentedpatch which will give an admin setting so user can set path to exclude 1.7
Comment #11
serjas CreditAttribution: serjas commentedpatch which will give an admin setting so user can set path to exclude 1.7
Comment #12
Sol Roth CreditAttribution: Sol Roth commentedIs there a way to only update jQuery for one particular theme? A Mobile theme? I'm working on a site that is stuck on Drupal 6, and I'm using theme switcher to provide the mobile experience http://examplesite.com?theme=mobiletheme. The Mobile theme version, does not need to have admin functionality or even node creation (for this particular site). They just want a really slick interface for searching and displaying content, so to run jQuery Mobile I would like to update only the version of jQuery when that theme is active? Could this be achieved with this module by adding something like active theme? Although I'm using theme switcher, there are other use cases for wanting jQuery to be updated different based on the theme, jQuery mobile being one of them.
Comment #13
Zach Harkey CreditAttribution: Zach Harkey commentedMarking as a duplicate of #1524944: Allow different version for administrative pages.
Comment #14
mpv CreditAttribution: mpv commentedPatch in #8 with correct paths.
Comment #15
Sarenc CreditAttribution: Sarenc commentedThis is a great addition to jquery_update. I vote for it being included.
Comment #16
cvharris CreditAttribution: cvharris commentedI combined both #11 and #4 together in this patch, adding an exception that the exception paths may still be an empty string, in case someone wanted to only specify fallback paths and not exclude updating jQuery altogether.
This patch may not seem like an important one at first, but let me just say this issue has frustrated me for awhile now. Drupal 6 is still running several sites but there are many cool plugins out there that need jQuery 1.7, so there had to be a way to use jQuery 1.7 when you needed it and keep 1.3 when you don't need it, or just exclude updating altogether. This also solves many issues experienced at #1067290 At least these two features give Drupal 6 developers easier control to fix jQuery through this popular module.
Comment #18
idebr CreditAttribution: idebr commentedI believe this issue is still relevant, as the patch in #16 has never been applied to the jquery_update repository.
Comment #19
RoySegall CreditAttribution: RoySegall commentedI can see this patch is against D6. Do we need to roll it against D7?
Comment #20
plachAn alternative approach for D7 is available at #2181095-2: Disable jquery update for admin path option in settings.
Comment #21
avillanueva-npr CreditAttribution: avillanueva-npr commentedI had issues with aliases but the change is minor (look at line 11)
$excluded = drupal_match_path($current_path, $update_exceptions) || drupal_match_path($alias_path, $update_exceptions);
So now if you have a content type where it's alias is post/* like on our sites this will still work.
Comment #22
avillanueva-npr CreditAttribution: avillanueva-npr commentedI needed to add the alias path.
Comment #23
SebCorbin CreditAttribution: SebCorbin commentedJust modifying the title to prevent misunderstanding with #1548028: Make the default jQuery version (1.4.4) for D7 an option
Comment #24
chevali CreditAttribution: chevali commentedis there a patch for the latest version? i need to disable it on the node/add path, as it's conflicting with hierarchical select
Comment #25
badzpeed CreditAttribution: badzpeed commentedIs there a patch for 2.4 ? i wanted to disable jquery update in the front page
Comment #26
markhalliwellWe are moving in a different direction.
Comment #27
markhalliwellActually I closed this one prematurely, sorry. There is specific use cases: #2309163: Exclude alternate jquery version for certain pages.
Comment #28
guardiola86 CreditAttribution: guardiola86 commentedForget this patch, I added duplicated stuff and didn't work for me. I'm gonna create a new one.
Comment #29
guardiola86 CreditAttribution: guardiola86 commentedComment #30
guardiola86 CreditAttribution: guardiola86 commentedAttached a new patch that solves the issues. Now you can exclude an administrative path from the alternate version and use the selected default. In frontend, if the path it's excluded then 'default' will be used.
Comment #31
markhalliwellJust a crazy idea here, so bear with me. There are so many different types of modules that break because Module A was built on 1.7 and Module B was built on 1.8. Module C was built on 1.4 (core) and it doesn't matter what version one chooses, if you have a ton of modules that all work differently, they certainly don't always work together.
Now my immediate "solution" would be to just say to Module A, B and C: "Update your module to work with the latest jQuery version". How realistic is that though?
The patch is pretty straightforward. Based on the toggle, it will either only include or explicitly exclude matched paths. That is an all or nothing approach.
What if we simply had a way to support any version for multiple paths? For example (I do not actually know off the top of my head what jQuery versions these modules support, FYI):
We could even provide a message to users warning them when multiple modules have defined the same path that have conflicting versions. This would be a better indicator that these two modules should work together or at least one of them should update their minimum supported jQuery version.
Comment #32
markhalliwellComment #33
Plazik CreditAttribution: Plazik commented#30 works for me. Thanks.
Comment #34
rcodina CreditAttribution: rcodina commentedPatch on #30 works for me too. However I see a big problem: If I want to exclude paths for administration pages, I cannot have different jquery version for admin pages and for frontend pages. So I'm forced to select "Defaul jQuery version" on administrative pages select.
Maybe we could have two different exclusion fields: one for admin and another for frontend pages.
Comment #35
Plazik CreditAttribution: Plazik commented@rcodina see my configuration in screenshot. It works for me.
Comment #36
paean99 CreditAttribution: paean99 commentedSeems to me that #31 is the beginning of a good solution. But the hook should be implemented by each modules themselves.
jQuery Update would give access to the different versions and continue to give essentially the sames options it has been giving (front-end, back-end and updates), taking care that the default versions are drupal core safe. While each modules and theme would call the specific version in their implemented path.
Comment #37
LeDucDuBleuet CreditAttribution: LeDucDuBleuet commented#30 works for me as well. Thanks.
Comment #38
markhalliwellI'm really not in favor of #30, especially now that #1969244: Specify jQuery version per theme has been committed. Has anyone taken a look at the proposal in #31 aside from @paean99?
Agreed and my example shows that (context, features, views) these would all be provided by the module themselves. If it were jquery_update providing them, it would look like
jquery_update_jquery_update_paths_alter()
since the hook (module name) isHOOK_jquery_update_paths_alter()
.I would, however, suspect that for certain modules, like Views, we would need to provide initial support until an actual patch for the module can be made, committed and then released. Given that Views is in core now (D8), the contrib version seems (to me) like it's taken a back seat in D7... so I'm not entirely sure this will happen?
Comment #39
paean99 CreditAttribution: paean99 commentedSorry, you are right.
I misunderstood your post and it was sufficiently clear :(
Comment #40
FrancewhoaThere is a related module at https://www.drupal.org/project/jqueries
This module allows multiple versions of jQuery instances loaded on the same page. Maybe some of its code could be adapted to the needs of this ticket. To change jQuery Update for specific paths.
Any volunteer? We would be happy to contribute Quality Assurance and documentation.
Comment #41
majorrobot CreditAttribution: majorrobot at Major Robot Interactive commentedJust ran into this issue myself on a project. While #30 resolves the immediate issue, #31 is a more flexible solution. I think it's a great idea.
Comment #42
majorrobot CreditAttribution: majorrobot at Major Robot Interactive commentedAttaching a patch that implements #31 with a drupal_alter(). This should allow other modules to change the jquery version by path. Note that this setting will still defer to the theme setting that is new in 7.x-3.x.
Comment #43
majorrobot CreditAttribution: majorrobot at Major Robot Interactive commentedComment #44
majorrobot CreditAttribution: majorrobot at Major Robot Interactive commentedHmm, looks like there's not much sense in making a path override if it doesn't also override the theme setting (since the theme setting would always override the path setting).
Here's an updated patch that addresses this.
Comment #45
mattew CreditAttribution: mattew commentedHere is a properly formatted patch (the precedent one had the full path hard-coded) and add a test for "current_path" so an internal path scheme may be use.
@majorrobot, thanks for your patch. Next time you may follow drupal.org guidelines to supply a patch.
Comment #46
markhalliwellCorrect. If a module implements
hook_jquery_update_path_alter
and it still doesn't work for a theme, then the theme can also implement the alter to override what the module already provided since theme alters are always invoked last.Comment #47
mattew CreditAttribution: mattew commentedI think we should simplify the alter hook, it should just override the version number, and all the logic with paths should be somewhere else.
If the jQuery Update provide a field to set versions by path, this code could be somewhere in this module. But if it's not a feature of the module for the moment, altering the version is enough and could be committed very soon.
In my case I would like to set a version regarding the Content Type of the current node, so using this hook I have to provide the path of the current node through the alter hook, so in my case it's a weird usage of this alter hook...
And of course, the alter hook should have another name if it's not based on path.
Comment #48
markhalliwellGiven that this is introducing just an alter hook, I would say that this is CNW.
It's generally considered "Best practice" to only introduce an alter hook for a generic hook implementation for modules (e.g. calling
module_invoke()
forjquery_update_paths
,hook_jquery_update_paths()
and then the alter after).That being said, I actually envisioned this issue also tackling what I said in #31. Specifically around providing some sort of conflict resolution and/or, at the very least, a message stating that one or more modules are in conflict.
Also, I semi-envisioned a module being able to declare a minimum (perhaps even maximum) jQuery version directly from their .info file. Granted, that wouldn't be specific to paths, but we could possibly introduce that as well via .info. Thoughts?
Suffice it to say, I believe this issue needs a lot more thought and work behind just a simple alter hook.
---
Re #47:
This issue is strictly about specific paths. I'm not sure opening it up to any arbitrary criteria is the best course of action ATM. I could be wrong, however from my experience opening up an issue to include everything but the kitchen sink makes for a very long issue.
That being said, perhaps I misread your comment and what you're saying is that we should also provide a generic "alter"? One that is executed after all the above logic is said and done? If so, that should definitely be a separate issue.
Comment #49
mattew CreditAttribution: mattew commentedYes, it's what I mean, of course a separate issue is required ;)
But behind that, an alter hook to provide a list of path is, as you will agreed I think, not very compliant with the usage of a alter hook. I mean, an alter hook is made for altering something, like some data provided to the hook, and here we pass an empty array and treat it right after that. An alter hook should be use to alter an existing behaviour, not creating a new one. It doesn't make sense to alter a feature which do not exists in the module, don't you think? Is this what you meant when you say that an alter hook should alter an existing generic hook? That's why I thought that the jQuery version number could be more suitable to be altered, than an empty array...
What do you mean about the minimum version in .info? It means that every path provided (through a hook_menu) for this module will use this jQuery version? Why not, but it sounds weird for me, I don't see any use case where it could be really useful.
Comment #50
samuel.seide CreditAttribution: samuel.seide at Mediacurrent commentedHere's a patch that can be used to create a hook to alter the jquery version. I used this and a custom module doing jquery_update_version_alter and added this code inside that:
This checks to see if the node is either being edited or it's a new node being created and if so it sets that page to jquery 1.9.
Comment #51
samuel.seide CreditAttribution: samuel.seide at Mediacurrent commentedHere's an updated version of the patch that moves this in front of the ajax portion of the code so that ajax will pull from the hook for it's version of jquery first instead of overriding the value we're supplying in the hook.
Comment #52
markhalliwellI'm still not convinced this is actually necessary. The above example indicates that the node edit page is different from the "default theme" (i.e. node view). Thus, this is a change that can be easily made on a per theme basis.
That being said, I would say that this issue has evolved as it's no longer really about "paths" at all, but rather a generic alter hook.
What logic one decides to do in that alter hooks is really up to them, even if it doesn't really make sense to me...
---
Regarding the actual patch:
Passing
$javascript
is completely unnecessary. This is only about altering the jQuery version that will be used.jquery_version
instead ofjquery_update_version
, e.g.hook_jquery_version_alter(&$version)
, as this isn't about altering thejquery_update
module version, but the framework version itself.Historically speaking, alter hooks are always at the end of "X", because you are altering whatever original logic determined the value to provide. This would/should include the ajax version here.
If this needs to be accounted for, I would say that we should also pass
$context = ['ajaxPageState' => $ajaxPageState]
along with the alter hook so users can utilize this information however they need to.Comment #53
markhalliwellWhoops, wrong title
Comment #54
markhalliwell#52 still needs to happen...
Comment #55
markhalliwellExplicit title
Comment #56
sokru CreditAttribution: sokru as a volunteer commentedThis patch should resolve #52.1, #52.2 and #52.3.
Comment #57
mcdruidSee #3312045: Plan for jQuery Update 7.x-4.0 release.