We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • This is the first patch in a series to improve ManagerManager and add additional functionality and flexibility to the MODx manager.
    What does it do?
    For frontend coding on MODx we have access to the following methods:
    getRegisteredClientStartupScripts()
    getRegisteredClientScripts()
    regClientScript()
    regClientStartupScript()
    regClientCSS()
    


    These are useful for snippets to attach resources/scripts in the correct place, rather than echo them wherever the snippet is called.

    Up to now the manager has not supported these methods, as output is echoed directly to screen rather than passed through the outputContent() method in document.parser.class.php.

    This patch adds support for these methods to the manager.

    Why is this useful?
    It provides a central system to include JavaScript/CSS files into the manager. This is useful when different widgets/input types all require the same Javascript files on a manager screen, and solves the issue of including duplicate copies.

    It is useful with ManagerManager in order to get resources loaded correctly - now they can be loaded from the mm_rules file, which will correctly load scripts such as Colorbox.

    The scenario where this becomes most useful is in the case of custom TV inputs, which was the reason for developing the patch.

    Notes
    The location of the function is not its final resting place - I will leave choosing that to someone better acquainted with MODx than myself!

    Download the patch from http://svn.modxcms.com/jira/browse/MODX-1292
      MAPLEDESIGN MODX development and MODX web design and custom development. Proud to serve UK and International clients!
      • 28215
      • 4,149 Posts
      Just as an FYI, this is already available in Revolution.
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 21056
        • 327 Posts
        I obviously came up against this problem for ManagerManager, and one of my original design goals for it was not to modify core files in any way.

        There was no way for MM to inject scripts into the header because of the timing of the events firing, and what was available at each stage (basically when the event that would insert headers ran, we had no way of knowing what headers would be needed).

        In the end I created a mini-APi within MM for including JS and CSS. This is perfectly valid for <script>s as you can insert them anywhere, but not so good for CSS which should be in the head. However since browsers don’t mind this, and the Manager is far from passing validation anyway, I took the pragmatic approach.

        Now we’re in a position when the Manager is being improved, this would be a most helpful addition!
          Author: ManagerManager plugin - customise your ModX manager interface

          Rckt - web development, Sheffield, UK