modxbot / migrate

A testground for migrating issues and other such fun
0 stars 0 forks source link

Need ability to dequeue (unqueue/unload) CSS and Javascript files #10101

Open modxbot opened 11 years ago

modxbot commented 11 years ago

everettg_99 created Redmine issue ID 10101

We need the ability to unload any file slated for inclusion on a MODX page via the regClientCSS, regClientStartupScript, regClientScript, regClientHTMLBlock and related functions.

This is especially important when modifying behavior in the manager: otherwise it's too coupled with the built-in Ext JS files that some custom modifications become impossible.

One part of the solution is to uniquely identify loaded CSS and JS file with a stub rather than with the href. For example, if one Snippet loaded up the jQuery library, another Snippet could force the jQuery library to be loaded from a different source (e.g. a CDN).

For example, instead of just keying off of a simple integer (from the regClientStartupScript() function):

 $this->sjscripts[count($this->sjscripts)]= ''; 

We should instead allow for a slug to identify the file being loaded:

 $this->sjscripts[$slug]= ''; 

That way you could easily call something like $modx->deregClientStartupScript('my-slug'); and have that script be unset from the array.

Without this functionality, modifying the MODX manager is nearly impossible in certain cases since these scripts are included by the core PHP classes (and not inside any template file).

See http://codex.wordpress.org/Function_Reference/wp_dequeue_script for comparison.