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.
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
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
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
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [Perchpole] Gallery Issue
By Toledoh - February 14, 2012
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"
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)
Tim (toledoh.com.au)
Re: [Toledoh] Gallery Issue
Hi, Tim (and Gerry)
Thanks for input. The problem is due to the way in which the user uploads images into their gallery. The one image-per-record is perfect (in terms of being able to pull the records out in any order, complete with pagination, etc.) but it's a slow way to build a big gallery full of images.
The alternative is to allow the user to upload mulitiple images per record. It's faster (because you can go and make a cup of tea whilst the system uploads your selected files) but you lose the ability to control the pagination.
Let's say we configure the getRecords code to return 3 records perPage...
If you employ the one-upload-per-record aproach the system will return 3 records. 3 records = 3 images. Nice and simple.
If you allow multiple uploads, however, the 1st record may have 3 images, the 2nd might have only one - the third may have 10. It's still 3 records - but now there are 14 images!
What I want to do is configure a way of returning the correct number of images per Page whilst maintaining some kind of pagination structure.
:0/
Perch
Thanks for input. The problem is due to the way in which the user uploads images into their gallery. The one image-per-record is perfect (in terms of being able to pull the records out in any order, complete with pagination, etc.) but it's a slow way to build a big gallery full of images.
The alternative is to allow the user to upload mulitiple images per record. It's faster (because you can go and make a cup of tea whilst the system uploads your selected files) but you lose the ability to control the pagination.
Let's say we configure the getRecords code to return 3 records perPage...
If you employ the one-upload-per-record aproach the system will return 3 records. 3 records = 3 images. Nice and simple.
If you allow multiple uploads, however, the 1st record may have 3 images, the 2nd might have only one - the third may have 10. It's still 3 records - but now there are 14 images!
What I want to do is configure a way of returning the correct number of images per Page whilst maintaining some kind of pagination structure.
:0/
Perch
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:
Hope this helps
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/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/