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

    I’m having a good time with ModX at the moment, it’s proving very easy to get to grips with.

    I was wondering if it’s possible to show the latest image from a directory, without the aid of a photo gallery?

    Any help would be appreciated. smiley

    Thanks,
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You could use a snippet or a TV, with @EVAL, and write the code to get the latest image from a given directory.

      http://il2.php.net/manual/en/ref.dir.php
        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
        • 29703
        • 217 Posts
        Ah. Thanks for the help, it’s a little above my station though. I really need to learn this php malarky if I’m to get anywhere in this world, heh.

        I take it there’s no shortcuts with this one then? undecided
          • 29703
          • 217 Posts
          Thanks GaneshXL,

          I did try googling but couldn’t find anything. I’ll give it a shot, cheers!
            • 29703
            • 217 Posts
            I’m having this problem seemingly:

            I’m using it in a snippet, though I’m not sure how to use the ’return()’ statement.

            PHP error debug
            Error: opendir([(base_url)]/assets/files/downloads/icons/) [function.opendir]: failed to open dir: No error

            Error type/ Nr.: Warning - 2
            File: C:\xampp\htdocs\modx\manager\includes\document.parser.class.inc.php(766) : eval()’d code Line: 8

            Any help would be great smiley
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Check the permissions on that directory. Make sure it’s set to at least 755, or maybe 777.
                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
                • 29703
                • 217 Posts
                Quote from: sottwell at Nov 15, 2007, 12:36 PM

                Check the permissions on that directory. Make sure it’s set to at least 755, or maybe 777.

                I’m running locally with XAMP on Windows, how do I go about changing permissions? I would be fine if it was remote huh
                  • 29703
                  • 217 Posts
                  Quote from: ganeshXL at Nov 15, 2007, 04:25 PM

                  PHP doesn’t parse [(base_url)] when used in a snippet - take a close look at your error msg:
                  Error: opendir([(base_url)]/assets/files/downloads/icons/) [function.opendir]: failed to open dir:

                  In a snippet, use something like:
                  $dir = $modx->config[’base_path’] . ’/assets/files/downloads/icons/’;



                  Ah thanks, I haven’t worked with snippets until now, so I thought it was all the same. However I’m now getting this error:

                  Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\modx\manager\includes\document.parser.class.inc.php(766) : eval()’d code on line 4

                  Bescause I know nothing about PHP I feel I stand very little chance of debugging this without help. I’m looking into learning at least the basics. undecided
                    • 29703
                    • 217 Posts
                    Okay sorry, I’m being a php tard. I’ve figured it out now.

                    My problem is that with this script it shows a link to the image, rather than the image itself. I’ll keep fiddling and try to change it, but any ideas in the mean time would be great.

                    Once i’ve figured this out I guess I can apply it to any free snippets of php I come across?
                      • 29703
                      • 217 Posts
                      Okay cool, I’ve got it to work!

                      I’m now trying to exclude any files starting with a ’.thumb’. I have the following bit of code I’ve scabbed from another post, but don’t know how to apply it to this situation:

                      if ( !preg_match('/\.thumb*/',$file) && $file != '.' && $file != '..' && $is_image )


                      A quick pointer would be appreciated smiley