We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18913
    • 654 Posts
    Here’s another question which probably has a simple answer that I’ve (again) overlooked.

    Put simply : I want to create a Radio TV for which one of the values is NULL. The TV then gets used in the display of the page to which it’s attached.

    At the moment, I have a definition like this :
    None==||My first value==blah


    The problem is that when "None" is selected what shows up on the page is "None". If I just use
    ==||My first value==blah


    then I correctly do not see any output. But that leaves the radio button unlabeled for the user. A single-selection drop down list displays the same behavior.

    Can anyone point out how I should accomplish this? I thought what I was doing was pretty straightforward...

    TIA,
    Matt
      • 18913
      • 654 Posts
      This
      None=={{}}||The output=={{outputchunk}}

      seems to do the trick.

      Matt
        • 22840
        • 1,572 Posts
        Quote from: mconsidine at Mar 17, 2011, 03:40 PM

        This
        None=={{}}||The output=={{outputchunk}}

        seems to do the trick.

        Matt

        Personally I would use:
        None=={{nothing}}||The output=={{outputchunk}}

        Then create the nothing chunk and leave it empty, only reason for this is I’m not sure how modx would handle an empty chunk call, would it actually try to look for it ??
          • 18913
          • 654 Posts
          Yes, I thought of that too, but after-the-fact. My thinking was that if it didn’t have a chunk name to deal with, then there wouldn’t be any database access taking place and the return would just be null. Since that worked, I figured I was right wink

          In all seriousness, I would have thought that the evaluation of "None==’’" or "None==" should have generated the desired result. But the former approach returned the two single quotes and the latter returned "None".

          Thanks for the thoughts ...
          Matt
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            list($item,$itemvalue) =  (is_array($itemvalue)) ? $itemvalue : explode("==",$itemvalue);
            if (strlen($itemvalue)==0) $itemvalue = $item;
            

            The code for handling the option value strings deliberately substitutes the value if it’s empty. Not sure why, exactly...I would think that if the value is empty it’s meant to be, and an empty value="" attribute would be generated in the HTML code.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org