We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30703
    • 51 Posts
    I’m trying to bind a directory to a TV via the Input Options Values. I’ve attached a screenshot of my setup...

    I would also like to give the user an option to select "No thumbnail". I have tried the following:

    None==''||@DIRECTORY /thumbnails
    


    but this doesn’t work. Is there a way to add an option to the binding results?

      Tom Dyer

      Designer/Animator/Web Developer - England, UK.
      http://www.bespokepixels.co.uk
      • 30703
      • 51 Posts
      No worries - I think I have found a way around this by using @EVAL instead.
      For the input options, I have:

      @EVAL return $modx->runSnippet('getThumbDirListing');
      


      Then I created a snippet called "getThumbDirListing" which contains the following code:
      <?php
      // Always give the "No thumbnail" option first.
        $output = "No thumbnail==null";
        $directory = "thumbnails";
        $files = glob('../'.$directory.'/*.*');
        $c = count($files);
        
        foreach($files as $image)
        {
          $output.="||".basename($image)."==$image";
        }
        
        return $output;​
      


      This does the trick, I just need to write a bit more to check file types - I don’t want to list files if they are not an image. I’m sure I can work that out aswell smiley

        Tom Dyer

        Designer/Animator/Web Developer - England, UK.
        http://www.bespokepixels.co.uk