We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8584
    • 14 Posts
    Is there a way to add to the template from a page?

    Like in zend framework we have a <?$this->headscript();?> in the layout(template) and if I have a need to load a validation script ,that needs to be in head, on pages with forms we add the to the page <?$this->headscript()->appendScript(’/js/jquery.validation.js’);?>

    Has anyone done anything similar. Sorry I inherited a Modx site after a Developer walked away from a project. So I am OJT for this customer.

    /edit
    Thx splittingred that did the trick


    Eric
      • 28215
      • 4,149 Posts
      You can either do this through a Template Variable so you can specify it per-resource (preferred), or using the $modx->regClientStartupScript() methods:

      http://rtfm.modx.com/display/revolution20/Adding+CSS+and+JS+to+Your+Pages+Through+Snippets
      http://api.modxcms.com/
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com