We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26799
    • 177 Posts
    I’d like to have a TV that listed the contents of a directory, I’ve tried a few things but nothing seems to work.

    I select "dropdown List" from the available inputs and I tried to use @EVAL and some php to build my array. but I’m just not getting it I guess, because my list remains empty.


    EDIT:

    I put this in the data binding textbox:
    @EVAL $handle = opendir('assets/flags'); return readdir($handle);



    here’s my current error:

    Warning: opendir(assets/flags): failed to open dir: No such file or directory in /home/wildpr/public_html/manager/includes/tmplvars.commands.inc.php(50) : eval()’d code on line 1

    Warning: readdir(): supplied argument is not a valid Directory resource in /home/wildpr/public_html/manager/includes/tmplvars.commands.inc.php(50) : eval()’d code on line 1

    I also can’t figure out how to backup to the assets directory.
      • 32982
      • 674 Posts
      think the folder havent permmisions or arent created
      hi
        Jabiertxof (formerly XYZVISUAL)
        My bussines: http://marker.es
        https://www.youtube.com/user/jabiertxof/videos
        • 25663 MODX Staff
        • 12,272 Posts
        What about just using @DIRECTORY that’s in the tmplvars.commands.inc.php file wink :

        <?php
                    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;
        ?>


        I’ve personally never used it, but seems like it returns a || delimited list of files.
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 26799
          • 177 Posts
          @directory worked perfect, Thank you. Why is this not in the documentation?
            • 33337
            • 3,975 Posts
            Because its discovered recently ... thanks to Ryan for hint wink ...
              Zaigham R - MODX Professional | Skype | Email | Twitter

              Digging the interwebs for #MODX gems and bringing it to you. modx.link
              • 26799
              • 177 Posts
              Wow some pretty useful code just showed up outta no-where. Thats scary, It hough yall were developing a CMS/CMF not a randomely usefull code generating AI. If Development goes much further it’ll be the world breaking AI from the terminator...

              Well Kudo’s Modx.
                • 26799
                • 177 Posts
                is there any ways to create custom @BINDiNGS that won’t be overwritten when one updates?
                  • 25663 MODX Staff
                  • 12,272 Posts
                  If they’re handy enough, they’ll be including in the next release. smiley

                  Feel free to contribute or toss out ideas, or I suppose would could put in a call to a custom extenders file too. Make a proposal and watch it happen. I think that @BINDINGS are way underutilized, under-understood and way too cool. smiley

                  I’d personally like to see @RSS, supporting multiple feeds from different sources. smiley
                    Ryan Thrash, MODX Co-Founder
                    Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                    • 22303 MODX Staff
                    • 10,725 Posts
                    I have a slightly different perspective on the future of @BINDINGS, one that I’ve formed over the last year while re-authoring MODx from scratch. IMO, @BINDINGS should be converted to a new type of component (or Element as it will be called in MODx 1.0) with corresponding tags, called something like:
                    [[@EVAL // all the content you ever wanted to include goes here]]
                    [[@SELECT * FROM [[@EVAL return $modx->getFullTableName('site_content');]] WHERE foo='bar';]]
                    This will completely expand the potential for what they can do, where they can be used, etc., and will make it easy for users to provide custom @BINDINGS that would never be lost on upgrades by simply creating new @BINDING elements in the same way they would create new snippets or plugins. And it will be super easy to translate legacy @BINDINGS to this format automatically.

                    Thoughts or other perspectives are welcome...
                      • 26799
                      • 177 Posts
                      now that’s what I’m talking about... That’s the SAUCE right there Ray. I look forward to the day. Couldn’t one theoretically use a plugin to parse custom @BINDINGS written in Snippits now, until 1.0 (http://modxcms.com/transforming-modx-oo-mvc-orm.html"" target="_blank" rel="nofollow">which is going to rock) is released?