Jump to content

  •  

  • Tutorial info Visit support topic

    • Added on: Jun 05 2011 08:35 AM
    • Date Updated: Jun 26 2011 04:27 AM
    • Views: 6554
     


    * * * * *
    1 Ratings

    Gallery 4.x Recent Image Adjustment

    How to adjust the default number of images displayed and change their ordering to random.

    Posted by AndyF on Jun 05 2011 08:35 AM
    Quite often, a forum administrator will want to adjust the number of recent Gallery images shown on the board index. There is already an article on doing this on 3.x but as 4.x is completely different rather than add to that I felt a new article was best. :)

    We are working with just one file so connect via FTP or your hosts file manager and open /admin/applications_addon/ips/gallery/sources/classes/hooks.php

    Around line 82, find...
    $recents = $this->registry->gallery->helper('image')->fetchImages( $this->memberData['member_id'], array( 'limit' => 20, 'sortKey' => 'date', 'sortOrder' => 'desc', 'unixCutOff' => GALLERY_A_YEAR_AGO ) );

    Change the 20 to what you want, here's ten for an example:

    $recents = $this->registry->gallery->helper('image')->fetchImages( $this->memberData['member_id'], array( 'limit' => 10, 'sortKey' => 'date', 'sortOrder' => 'desc', 'unixCutOff' => GALLERY_A_YEAR_AGO ) );


    Some administrators may also prefer random images instead of the last uploaded as this is quite a popular change and adds a bit of variety too, especially for Galleries that are not heavily used. This again is very easy to achieve. :) , the same line needs adjusting for its 'sortKey' and optionally the 'sortOrder' removing. Here is the default of twenty images but random:

    $recents = $this->registry->gallery->helper('image')->fetchImages( $this->memberData['member_id'], array( 'limit' => 20, 'sortKey' => 'rand', 'unixCutOff' => GALLERY_A_YEAR_AGO ) );

    And here is ten images, again random:

    $recents = $this->registry->gallery->helper('image')->fetchImages( $this->memberData['member_id'], array( 'limit' => 10, 'sortKey' => 'rand', 'unixCutOff' => GALLERY_A_YEAR_AGO ) );


    Save the change / re-upload the file and you're done.

    Powered by Tutorials 1.4.1 © 2017, by Michael McCune
    IPB Skin By Virteq