We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21792
    • 37 Posts
    One of the reasons I love MODx is the templating side of things - The templates, chunks, snippets etc work in a very similar way to a CMS I started t build myself - It recursed over the docuument untill all recognised tags had been parsed. One thing I wanted to do was to have some delays, so that I could retrospecivly add stuff back into the document if logic that was to execute later made it necessary.

    For example, If a snippet was to output the html for some jQuery based tabs, I would want the html to include another CSS file, jQuery and the Tabs plugin (if not already included); and I would want this in the <head></head> section

    Is there any way to do this in MODx?
      • 3749
      • 24,544 Posts
      You can inject CSS and JS into the head section of a page from inside a snippet with the $modx->regClientCSS() and $modx->regClientStartupScript methods. You can insert content anywhere on a page dynamically with a snippet using $modx->setPlaceholder() and putting placeholder tags on the page.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting