We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37523
    • 141 Posts
    How can I create a TV that acts as a button that when pressed runs a snippet?

    The idea I have is within a Resource's Template Variables tab there would be a button that says "Email me" which when pressed would run a snippet that will email the current resource to a specific address.

    I am aware of the EmailResource package which is good but there are way too many options for my end users and I really would like just one button, no other options. It avoids confusion.

    Any suggestions welcome.

    Many thanks in advance.
      Glyn Szasz
      Sydney, Australia

      Happy to help (when can) and happy to learn

      If you are a Sydney based MODX developer would love to hear from you. Please contact me.
      • 4172
      • 5,888 Posts
      should not be that difficult to create a custom-TV-inputtype, which would do that.
      It could run a processor, when the button was clicked.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 3749
        • 24,544 Posts
        Take a look at the Notify extra's TV. It makes the TV caption a button that launches a page containing a snippet. It's a regular text TV.

        For a long time now I've been meaning to rewrite EmailResource to work the same way, but I never seem to find the time to do it.

          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
          • 37523
          • 141 Posts
          Quote from: BobRay at Sep 19, 2015, 05:43 PM
          Take a look at the Notify extra's TV. It makes the TV caption a button that launches a page containing a snippet. It's a regular text TV.
          I notice within the caption you have the
          <button id="nf-b" onClick="nf()"> Launch Notify </button>

          Where is the nf() method? How do I link this to my snippet call?
            Glyn Szasz
            Sydney, Australia

            Happy to help (when can) and happy to learn

            If you are a Sydney based MODX developer would love to hear from you. Please contact me.
            • 3749
            • 24,544 Posts
            It's JavaScript in the code of the plugin. It creates a form, then appends it to the document and submits it. The action of the form is set to a page with the Notify snippet on it.
              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