We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51020
    • 670 Posts
    HI again!

    I have a TV which creates a listbox out of values from a MIGX call in another page.
    I have created a TV which uses the following to pull in the details I need:
    @EVAL return $modx->runSnippet('getImageList',array('tpl'=>'@CODE:[[+COLOUR]]','outputSeparator'=>'||','tvname'=>'TVNAME','docid'=>'IDOFRESOURCE'));
    


    So this works, and outputs a list of COLOURS used in the original resource.
    But, I want the first value in the listbox to be blank, so that users can decide whether they want to show a colour or not.

    I read something about using UNION to add a blank field at the beginning of the call, but I can't work out the syntax.

    Thanks as always!
    Andy

    This question has been answered by BobRay. See the first response.

      • 17301
      • 932 Posts
      Not sure if it'll work but have you tried entering a blank space followed by || before your @EVAL ?
        ■ email: [email protected] | ■ website: https://alienbuild.uk

        The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
        • 51020
        • 670 Posts
        Quote from: lkfranklin at Jan 26, 2018, 03:48 AM
        Not sure if it'll work but have you tried entering a blank space followed by || before your @EVAL ?

        Thanks - just tried it, but it didn't work unfortunately.
        • discuss.answer
          • 3749
          • 24,544 Posts
          Here are some more things to try:

          @EVAL return ' ||' . $modx->runSnippet('getImageList',array('tpl'=>'@CODE:[[+COLOUR]]','outputSeparator'=>'||','tvname'=>'TVNAME','docid'=>'IDOFRESOURCE'));
          


          @EVAL return '||' . $modx->runSnippet('getImageList',array('tpl'=>'@CODE:[[+COLOUR]]','outputSeparator'=>'||','tvname'=>'TVNAME','docid'=>'IDOFRESOURCE'));
          


          @EVAL return '---||' . $modx->runSnippet('getImageList',array('tpl'=>'@CODE:[[+COLOUR]]','outputSeparator'=>'||','tvname'=>'TVNAME','docid'=>'IDOFRESOURCE'));


          @EVAL return ' ||' . $modx->runSnippet('getImageList',array('tpl'=>'@CODE:[[+COLOUR]]','outputSeparator'=>'||','tvname'=>'TVNAME','docid'=>'IDOFRESOURCE'));
          

            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
            • 51020
            • 670 Posts
            Quote from: BobRay at Jan 26, 2018, 11:56 PM
            Here are some more things to try:

            @EVAL return ' ||' . $modx->runSnippet('getImageList',array('tpl'=>'@CODE:[[+COLOUR]]','outputSeparator'=>'||','tvname'=>'TVNAME','docid'=>'IDOFRESOURCE'));
            


            @EVAL return '||' . $modx->runSnippet('getImageList',array('tpl'=>'@CODE:[[+COLOUR]]','outputSeparator'=>'||','tvname'=>'TVNAME','docid'=>'IDOFRESOURCE'));
            


            @EVAL return '---||' . $modx->runSnippet('getImageList',array('tpl'=>'@CODE:[[+COLOUR]]','outputSeparator'=>'||','tvname'=>'TVNAME','docid'=>'IDOFRESOURCE'));


            @EVAL return ' ||' . $modx->runSnippet('getImageList',array('tpl'=>'@CODE:[[+COLOUR]]','outputSeparator'=>'||','tvname'=>'TVNAME','docid'=>'IDOFRESOURCE'));
            


            Thanks - they all work actually! The only thing is the blank field is very hard to select - it's not the full line-height of the ones with text in, but it's usable. Thanks again Bob - I have just donated on your site.
              • 3749
              • 24,544 Posts
              Thanks! I'm kind of surprised that they all work. wink

              If you load the Manager page, turn on Dev. tools in your browser (Ctrl-shift-i), click on the little square with the arrow at the lower left, then on the blank field, you should be able to see a class or ID in the code in the window at the bottom. You may be able to style it with some extra CSS if your CSS is loaded after the MODX CSS. You may need to specify it as !important.

              A plugin attached to OnDocFormRender or OnDocFormPrerender can load the CSS:

              $modx->RegClientCSS('assets/css/my_style.css');
              return;
                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
                • 51020
                • 670 Posts
                Quote from: BobRay at Jan 27, 2018, 02:51 PM
                Thanks! I'm kind of surprised that they all work. wink

                If you load the Manager page, turn on Dev. tools in your browser (Ctrl-shift-i), click on the little square with the arrow at the lower left, then on the blank field, you should be able to see a class or ID in the code in the window at the bottom. You may be able to style it with some extra CSS if your CSS is loaded after the MODX CSS. You may need to specify it as !important.

                A plugin attached to OnDocFormRender or OnDocFormPrerender can load the CSS:

                $modx->RegClientCSS('assets/css/my_style.css');
                return;

                Nice idea - thanks Bob. In the end I decided to just add `none||` to the query, instead of an empty field - and then if 'none' is selected, it ignores the TV. Saves having to dig into the manager CSS. Thanks for your help with this though - it's always much appreciated.

                Andy