We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36551
    • 416 Posts
    I have a client that would like to tailor the email response from their contact form based on the topic they choose in a pull down.

    We'll need an easy way for the client to update the response content. So I was thinking I could create a set of TVs on the form page that contain the custom response content. Then put an output modifier on a placeholder in the emailtpl that would do something like, if topic one choose TV2, if topic two choose TV2, etc. There would be five to ten topic and response choices.

    Would this work? What would the placeholder output modifier look like?

    Would this have to be done via snippet? (my php knowledge is pretty low).

    Thank you!

    Revo 2.2.2
      • 4172
      • 5,888 Posts
      not sure it this is possible in the email-chunk:

      [[*TV[[+topic]]]]


      if not you can use a formit-hook with something like that:

      $topic=$hook->getValue('topic');
      $hook->setValue('output',$modx->resource->getTVvalue('TV'.$topic));
      return true;


      and use the placeholder
      [[+output]]
      in your email-chunk
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 36551
        • 416 Posts
        Bruno17

        Thanks for the quick response. Upon reading your suggestion and my original post, I think I didn't explain my objective clearly.

        I need to put more than just the topic value in the email, a place holder will do that nicely.

        This form will be used to request specific information about a specific topic. So if they ask a question on topic A, a couple of paragraphs of helpful text, links etc will be inserted into the email sent to the submitter. If they ask about topic B, different information will be sent to the submitter.

        So I need a way to insert the content of one of the several "helpful text" TVs based on the topic selected.

        Can an output modifier do this? Do I need a custom snippet?

        Thanks!
          • 36551
          • 416 Posts
          I've had another idea about how to accomplish this. I ran a quick test without success. However, with a little help might this work?

          I setup drop down field in my form where tv.topic1 is a RTF TV attached to the page containing the form.

          <select name="topic"> 
          <option value="">Select Type of Project </option> 
          <option value="[[+tv.topic1]]">Topic 1</option> 
          <option value="[[+tv.topic2]]">Topic 2</option> 
          </select> 


          I then put a
          [[+tv.topic]]
          placeholder in the emailtpl. I also tried
          [[+topic]]
          .

          However, the contents of the selected tv didn't appear on the email sent out. I can imagine the problem has something to do with how the fields are all processed and in what order etc.
          [ed. note: terrybarth last edited this post 11 years, 10 months ago.]
            • 4172
            • 5,888 Posts
            this is what I did above. (both variants)

            if the the selected topic is 'one'

            and you have a TV for the related helpfull text with name helpfulltext_one

            you can try:
            [[*helpfulltext_[[+topic]]]]


            but this will only work, if the form and formit is on the same page as your TVs
            And I'm not sure if this will work at all.

            The second version is to use a hook-snippet which does this (same scenario)

            $topic=$hook->getValue('topic');
            $hook->setValue('helpfulltext',$modx->resource->getTVvalue('helpfulltext_'.$topic));
            return true;


            You need to name your helpfulltext-tv suffixed by the topic.
            If that's not possible you can use switch/case - conditions in your hook-snippet.


            [ed. note: Bruno17 last edited this post 11 years, 10 months ago.]
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 36551
              • 416 Posts
              It works!!! Thank you!!!

              I have to say I didn't realize what you were proposing the first time around. My apologies for missing that. The hook, snippet approach does the trick.

              My client will be very pleased. Thank you!