We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14677
    • 54 Posts
    Hey Guys,

    Wonder if you can help, below is my tv setup for creating a list of images in a specified directory.

    Template Variable Name: [*staff_image*]
    Input Type: DropDown List Menu
    Input Option Values: @DIRECTORY assets/images/management_images/
    Input Option Values: EMPTY

    Widget: Image
    Widget Properties: Standard image stuff

    What I am trying to do is add a "Please select" so that if it’s not relevant the user will leave the TV set as Please Select and then no image will be displayed, because as it is currently ALL templates where that TV is assigned has an image assigned to it whether needed or not.

    I have tried the following:
    Please Select== ||@DIRECTORY assets/images/management_images/

    However this purely puts Please select as it should, but then a second options of "@DIRECTORY assets/images/management_images/" instead of the list of images.

    Any help would be greatly appreciated.

    Thanks in advance,
    Jonathan
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      I would put in a "no image" image in the specified folder; it should be named in such a way that it will be the first one in the list.
        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
        • 14677
        • 54 Posts
        Ok great, I will look at doing that and putting in a 1px gif or something. Cheers for the reply smiley
          • 14677
          • 54 Posts
          Is there a way of relabelling it though? Purely to get rid of the file extention etc?

          I need to make this as simple as possible for the user experience.
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Not really. In the way such pre-packaged things usually are, TVs do have some limitations due to the fact that what was coded is what you get.
                       case 'DIRECTORY' :
                            $files = array ();
                            $path = $modx->config['base_path'] . $param;
                            if (substr($path, -1, 1) != '/') {
                                $path .= '/';
                            }
                            if (!is_dir($path)) {
                                die($path);
                                break;
                            }
                            $dir = dir($path);
                            while (($file = $dir->read()) !== false) {
                                if (substr($file, 0, 1) != '.') {
                                    $files[] = "{$file}=={$param}{$file}";
                                }
                            }
                            asort($files);
                            $output = implode('||', $files);
                            break;
            

            If you were willing to hack the manager/includes/tmplvars.commands.inc.php, you could add a line
            $output = implode('||', $files);
            $output = '||' . $output;
            break;

            Even better, if you are good with javascript and the DOM, you could create a custom rule for ManagerManager to add the empty option to the beginning of the select via javascript.
              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
              • 14677
              • 54 Posts
              Cool, I may have to run the hack by some colleagues as this might be a problem when it comes to upgrading etc so they might not go for it. However I will discuss the options.

              Thanks again for all the detailed responses, it’s greatly appreciated.

              Jonathan
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                I’ll play around and see if I can’t figure out such a ManagerManager rule, as this does come up from time to time and would be a useful function. I’ve been meaning to learn how to manipulate ManagerManager for some time, anyway.
                  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
                  • 20413
                  • 2,877 Posts
                  Just to clarify
                  Input Option Values: EMPTY
                  This is the "Default Value" of the TV to use.

                  My tip is to use multiselect box instead and for TV description
                  use "Select pictures."


                    @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