Gallery Issue

5 posts by 4 authors in: Forums > CMS Builder
Last Post: February 15, 2012   (RSS)

I recently created a very simple gallery solution for a client. It runs the same as ordinary multi-page record section except it has far fewer fields:

  • Gallery Category (list) - selects which category the record appears in.

  • Title (text field)

  • Image (upload)

  • Caption (text field)


  • The records are displayed using a simple getRecords call.

    list($galleryRecords, $galleryMetaData) = getRecords(array(
    'tableName' => 'gallery',
    'allowSearch' => false,
    'where' => " galleryCat LIKE '%$selectedGalleryNum%' ",
    'perPage' => '6',


    It's nice and simple and works pretty flawlessly. The only caveat is that in order to maintain the 'perPage' structure you must only upload one image per record. This makes uploading rather slow because it would be easier to upload 12 pictures into one record in a single hit.

    The gallery would still display all the images but you'd end up with far more pictures on each page than intended (because the perPage instruction controls the number of records returned - not the number of images per record.)

    My question is, how can I rework/modify my code to limit the number of images shown on each page?

    :0/

    Perchpole

    Re: [Perchpole] Gallery Issue

    Hi Antar,

    If I understand you correctly, there's a post that discusses that topic at:
    http://www.interactivetools.com/forum/gforum.cgi?post=75239

    There's also a detailed explanation of how to use this with Dynamic Drive’s Thumbnail Viewer II in my CMSB Cookbook http://www.thecmebcookbook.com

    Best,

    Jerry Kornbluth
    The first CMS Builder reference book is now available on-line!







    Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

    Re: [Perchpole] Gallery Issue

    I may be missing something, but why not just have a single upload field, and limit the number of images to 6?

    I use this quite often, and put the slides in a slideshow, and use "shuffle" to randomise the order of the images.

    If you wanted to, don't limit the upload field, shuffle the records, then do one of those "$count = $count + 1" loops and "if $count = 6 then break"
    Cheers,

    Tim (toledoh.com.au)

    Re: [Perchpole] Gallery Issue

    By Jason - February 15, 2012

    Hi Perch,

    Probably the simplest approach would be to have each gallery be a separate record in the gallery section. A gallery can have an images upload field that would have a variable number of images uploaded to it. If, on your gallery page you can retrieve a single gallery record, you can paginate your images by querying the uploads table directly.

    To get records out of the uploads table, you need 3 things:
    - the table name of the section the images were uploaded to
    - the field name of the upload field in that section
    - the record number of the record in the section the images were uploaded to.

    In this example, we assume the field name is "images" and that you have already retrieved your gallery record in a variable called $gallery

    example:

    list($galleryImages, $galleryMetaData) = getRecords(array(
    'tableName' => 'uploads',
    'allowSearch' => false,
    'loadCreatedBy' => false,
    'where' => "tableName = 'gallery' AND fieldName = 'images' AND recordNum = '".intval($gallery['num'])."'",
    'perPage' => 6,
    ));


    Hope this helps
    ---------------------------------------------------
    Jason Sauchuk - Project Manager
    interactivetools.com

    Hire me! Save time by getting our experts to help with your project.
    http://www.interactivetools.com/consulting/