We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18646
    • 106 Posts
    I’ve tried every possible combo to make one or two button images display using PHx, but I just can’t get the thing to work:

    [+phx:if=`[*submit_type]`:is=`1`:then=`button_1.jpg`:else=`button_2.jpg`+]


    I set up a TV named submit_type and added two radio buttons: Button 1 and Button 2. Their values look like this:

    Button One==1||Button Two==2


    I’m making the PHx call from a chunk that looks like this:

    <input name="submit" src="/path/to/button/[+phx:if=`[*submit_type]`:is=`1`:then=`button_1.jpg`:else=`button_2.jpg`+]" type="image" value="Send Feedback" />


    Based on which radio button the user selects in the visual editor, the correct image should show, but it’s not. It’s not a broken image, the PHx is not processing. What am I doing wrong?

    Regards,
    Matt
      • 20413
      • 2,877 Posts
      Use [*submit_type*] instead of [*submit_type]
      and make sure it outputs the 1
        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
        • 15022
        • 31 Posts
        if your chunk is being used by a snippet, like Ditto, use:
        [+phx:if=`[+submit_type+]`:is=`1`:then=`button_1.jpg`:else=`button_2.jpg`+]


        if it is being output directly on a page use:
        [*phx:if=`[*submit_type*]`:is=`1`:then=`button_1.jpg`:else=`button_2.jpg`*]


        note the use of + or *

        Hope this helps.
          illegitimati non carborundum
          • 18646
          • 106 Posts
          So last night i realized that I can do this without PHx at all. All I need to do is:

          <img src="/path/to/image/[*submit_type*]" />


          If the TV option values are defined like so:

          Button 1==button_1.gif||Button 2==button_2.gif


          The raw output gives me exactly what I’m looking for. Just took me a few hours to realize it! Thanks for the tips anyway guys. This topic is closed.

          Regards,
          Matt