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

    I am currently developping a new site with Revo and I wonder if there is a simple solution to get the timestamp information of a file ?

    Ideally a snippets that would take a path as input and return informations about the file itself (a bit like filelister snippet on directories).

    Thanks for help

    Philippe [ed. note: Fildefer57 last edited this post 15 years ago.]
      • 9674
      • 170 Posts
      Anyone ?

      Is it time off for summer vacation ?


      cool
        • 33976 ☆ A M B ☆
        • 571 Posts
        Hello Philippe,

        I guess you’ll have to rely on filemtime, filectime or stat (in French, just for you ;p)
        Hope that’ll help
          • 9674
          • 170 Posts
          Merci,

          ANd for your international friends, I will have to code it now... haha

          Philippe
            • 33976 ☆ A M B ☆
            • 571 Posts
            Shouldn’t be that hard…
            <?php
            if (file_exists($file)) {
                $o = $file .' has been edited on : ' . date ($format, filemtime($file));
            } else {
                $o = 'You must define a valid file';
            }
            ?>
            

            And then
            [[!modifiedOn?
            &file=`[[++assets_path]]to/your/file.ext`
            &format=`F d Y H:i:s`
            ]]
              • 9674
              • 170 Posts
              Merci Again !


              Philippe
                • 9674
                • 170 Posts

                Hi,

                Thanks to Romain for help with php ...

                Now I face a problem with caching, I guess huh??

                To ease understanding, I have created the following test case :

                On the page : http://www.vgd-pinceaux.eu/test.html

                I have the code :


                
                7<br/>
                [[!Gallery? &thumbWidth=`195` &thumbHeight=`140` &album=`7` &orderby=`date`]]
                [[+Gallery]]
                
                8<br/>
                [[!Gallery? &thumbWidth=`195` &thumbHeight=`140` &album=`8` &orderby=`date`]]
                [[+Gallery]]
                
                9<br/>
                [[!Gallery? &thumbWidth=`195` &thumbHeight=`140` &album=`9` &orderby=`date`]]
                [[+Gallery]]
                
                10<br/>
                [[!Gallery? &thumbWidth=`195` &thumbHeight=`140` &album=`10` &orderby=`date`]]
                [[+Gallery]]


                I modified dirtily Shaun’s chunck for default output template to call Romain’s modifiedOn snippet :

                <div class="[[+cls]]">
                <a href="[[+linkToImage:if=`[[+linkToImage]]`:is=`1`:then=`[[+image_absolute]]`:else=`[[~[[*id]]?
                &[[+imageGetParam]]=`[[+id]]`
                &[[+albumRequestVar]]=`[[+album]]`
                &[[+tagRequestVar]]=`[[+tag]]` ]]`]]">
                
                <img class="[[+imgCls]]" src="[[+thumbnail]]" alt="[[+name]]" />
                </a>
                <p>
                <!-- this should not be there, but otherwise, variables don't get initialized  -->
                
                assets/components/gallery/files/[[+gallery.id]]/[[+filename]]
                
                <!-- this is the call to Romain's snippet  -->
                
                [[!modifiedOn?
                &file=`assets/components/gallery/files/[[+gallery.id]]/[[+filename]]`
                &format=`F d Y H:i:s`
                ]]</p>
                </div>


                Two problems that seems relative to caching :

                Call to modifiedOn does not work if [[+gallery.id]] and [[+filename]] are not called.displayed before the snippet.

                Gallery number (gallery.id) is not changed with each subsequent Gallery call resulting in "You must define a valid file" message after the first call.

                I must have done something wrong ?

                Any idea about what the problem is ?

                Thanks

                Philippe
                  • 33976 ☆ A M B ☆
                  • 571 Posts
                  Philippe,

                  As far as i understand, your last piece of code is a chunk used as tpl in another snippet, am i right ?
                  If so, i guess you don’t need to call the snippet uncached. For placeholders problems, i assume you are not using Revo 2.1.3. If not you should really upgrade, since nested placeholders had some kind of caching issue fixed in 2.1.3
                    • 9674
                    • 170 Posts
                    Yes,

                    The template is the default one.

                    Revo version 2.1.2.pl.

                    I’ll update it to 2.1.3 immediatly to see if there is some changes.


                    Philippe
                      • 9674
                      • 170 Posts
                      Hi,

                      Modification done : Upgraded to 2.1.3.pl

                      called changed in the http://vgd-pinceaux.eu/test.html page to :

                      
                      7<br/>
                      [[!Gallery? &thumbWidth=`195` &thumbHeight=`140`  &album=`7` &orderby=`date` &tpl=`galItemThumbmod`]]
                      [[+Gallery]]
                      
                      8<br/>
                      [[!Gallery? &thumbWidth=`195` &thumbHeight=`140`  &album=`8` &orderby=`date` &tpl=`galItemThumbmod`]]
                      [[+Gallery]]
                      
                      9<br/>
                      [[!Gallery? &thumbWidth=`195` &thumbHeight=`140`  &album=`9` &orderby=`date` &tpl=`galItemThumbmod`]]
                      [[+Gallery]]
                      
                      10<br/>
                      [[!Gallery? &thumbWidth=`195` &thumbHeight=`140`  &album=`10` &orderby=`date` &tpl=`galItemThumbmod`]]
                      [[+Gallery]]


                      galItemThumbmod chunck is :

                      <div class="[[+cls]]">
                      <a href="[[+linkToImage:if=`[[+linkToImage]]`:is=`1`:then=`[[+image_absolute]]`:else=`[[~[[*id]]?
                      &[[+imageGetParam]]=`[[+id]]`
                      &[[+albumRequestVar]]=`[[+album]]`
                      &[[+tagRequestVar]]=`[[+tag]]` ]]`]]">
                      
                      <img class="[[+imgCls]]" src="[[+thumbnail]]" alt="[[+name]]" />
                      </a>
                      <p>
                      <!-- this should not be there, but otherwise, variables don't get initialized  -->
                      
                      assets/components/gallery/files/[[+gallery.id]]/[[+filename]]
                      
                      <!-- this is the call to Romain's snippet  -->
                      
                      [[!modifiedOn?
                      &file=`assets/components/gallery/files/[[+gallery.id]]/[[+filename]]`
                      &format=`F d Y H:i:s`
                      ]]</p>
                      </div>


                      Romain’s modifiedOn Snippet code is :

                      <?php
                      if (file_exists($file)) {
                      
                          $o =$file .' has been edited on : ' . date ("F d Y H:i:s.", filemtime($file));
                      } else {
                          $o = 'You must define a valid file';
                      }
                      return $o;



                      And still this caching issue.

                      Thanks for help.


                      Philippe