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

    i’ve got a little question. Isn’t it possible to use a code in TVs like the following one?

    @DIRECTORY assets/images/slideshows/[*alias*]


    Thanks for help!

    Regrads,
    Martini
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      TVs don’t play well with nested TVs; it’s how the parser processes them. If this is to produce a list of items for the front-end, you can use a snippet to get the TV value and generate 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
        • 18481
        • 13 Posts
        I’m trying to generate a multi-select-list with images for a slideshow. The path to the images should be the same like the ressource-alias.

        I created the nippet now and wrote the snippet call ( [[SlideshowPath]] ) into the TV. But that doesn’t work too.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Well, you would have to edit each resource that is using this TV and edit its copy of the TV to have the alias hard-coded.

          My intention was to use a snippet instead of a TV. With $modx->documentObject[’alias’] to get the page’s alias, then PHP code to generate the list from the files in the directory.
            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
            • 18481
            • 13 Posts
            With this solution isnt’t it possible for the admin to select the images per select-box, right?
              • 4172
              • 5,888 Posts
              you can try this:

              @EVAL $doc = $modx->getPageInfo($_REQUEST['id'], 0, 'alias');return '@DIRECTORYassets/images/slideshows/'.$doc['alias'];
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 18481
                • 13 Posts
                Quote from: Bruno17 at Mar 29, 2010, 08:36 AM

                you can try this:

                @EVAL $doc = $modx->getPageInfo($_REQUEST['id'], 0, 'alias');return '@DIRECTORYassets/images/slideshows/'.$doc['alias'];



                Hey Bruno,

                your code works. I modified it a little bit, but it doesn’t work. Are if-conditions forbidden in a template? That’s my current code:
                @EVAL $doc = $modx->getPageInfo($_REQUEST['id'], 0, 'alias');$path='assets/images/slideshows/'.$doc['alias'].'/'; if(is_dir('../' . $path)){return '@DIRECTORY'.$path}else{return '@DIRECTORY assets/images/slideshows/'};


                //EDIT
                I doesn’t get an output of the return. Tried it with print_r, echo and return.
                  • 4172
                  • 5,888 Posts
                  try this:

                  @EVAL $doc = $modx->getPageInfo($_REQUEST['id'], 0, 'alias');$path='assets/images/slideshows/';return (is_dir($modx->config['base_path'].$path.$doc['alias'].'/'))?'@DIRECTORY'.$path.$doc['alias']:'@DIRECTORY'.$path;
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 18481
                    • 13 Posts
                    Quote from: Bruno17 at Mar 29, 2010, 09:44 AM

                    try this:

                    @EVAL $doc = $modx->getPageInfo($_REQUEST['id'], 0, 'alias');$path='assets/images/slideshows/';return (is_dir($modx->config['base_path'].$path.$doc['alias'].'/'))?'@DIRECTORY'.$path.$doc['alias']:'@DIRECTORY'.$path;


                    Works really fine. Thx a lot!