Making a row of columns insert files/fields from a database section based upon a checkbox, alternating order

4 posts by 2 authors in: Forums > CMS Builder
Last Post: February 13, 2014   (RSS)

By Codee - February 7, 2014

Hi,

Right now my client has a graphic row of rotating images pulling from her testimonials section, based upon male OR female for the entire row. So the output in the browser looks like, for female,

female1-graphic | female 2 graphic | female3 graphic | female4 graphic | female 5 graphic

then after 2 or 3 seconds another row replaces the row above, but with male records from the testimonials section and looks like

male1-graphic | male 2 graphic | male3 graphic | male4 graphic | male 5 graphic

then it continues to rotate in/out the same way continuously. [screenshot attached]

What the client wants this rotator to do is have each row display as girl-boy order so,

female-graphic | male  graphic | female graphic | male graphic | female  graphic

Here's the code I use for each single rotation (connects to an image rotator that is embedded in the header of the document that I got from dynamic drive a couple years ago)/

            <!--first set begin-->
            <div class="gallerycontent" subject="Featured Golf Coach Testimonials">

            <?php
              /* STEP 1: LOAD RECORDS - Copy this PHP code block to the TOP of your page BEFORE anything else. */
              require_once "/home/domainname/public_html/lifgAdmin/lib/viewer_functions.php";

              list($testimonialsRecords, $testimonialsmetaData) = getRecords(array(
                'tableName'   => 'testimonials',
                'where'             => " (featured = '1') AND (female = '1') ",
                'orderBy'     => 'RAND()',
                'limit'       => '5',
              ));
              $testimonialsRecord = @$testimonialsRecords[0]; // get first record

            ?>
         <!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
        <center><b><font size=3 face="arial" color="#ffffff">Testimonials from Linda's Golf Students</font></b></center>
            <center>
             <table bgcolor="#5A7BAD" border="0" bordercolor="#000000" cellpadding="0" cellspacing="0">
                <tr>
                    <td valign='bottom' >  <center>
                        <?php foreach ($testimonialsRecords as $record): ?>

                  <!-- STEP 2a: Display Uploads for field 'photo' (Paste this anywhere inside STEP2 to display uploads) -->
                <!-- Upload Fields: num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
                <?php foreach ($record['photo'] as $upload): ?>

                  <?php if ($upload['hasThumbnail']): ?>
                   <a href="<?php echo $record['_link'] ?>" target="_blank" border="0"> <img src="<?php echo $upload['thumbUrlPath3'] ?>" width="<?php echo $upload['thumbWidth3'] ?>" height="<?php echo $upload['thumbHeight3'] ?>" border="0" alt="" /></a/>
                            
                            <?php break; ?> 
                            
                  <?php elseif ($upload['isImage']): ?>
                <img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" border="0" alt="" /><br/>

                  <?php else: ?>
                    <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>

                  <?php endif ?>
                          <?php endforeach ?>
                  <!-- STEP2a: /Display Uploads -->

                       <?php endforeach; ?>

                      <!-- /STEP2: Display Records -->
                        </center>
                         </td>
                    </tr>
                </table>
                </center>
                <center><b><font size=2 face="arial" color="#ffffff">Click on the Thumbnail to Read What Each Says</font></b></center>
            
                        </div>
<!--first set end-->

and the next row obviously has the where statement changed to

'where'             => " (featured = '1') AND (male = '1') ",

So, I don't know how to get the graphics for the testimonials to insert and display on the visual row in female-male order.

Any and all help is appreciated.

By Dave - February 12, 2014

Hi Terry,

So what would the plain HTML for something like this be?  There's where I always start.  I figure out what the hard-coded HTML would be and then figure out how to automate it with CMSB.  

Is it a list of 5 female thumb links and then 5 male thumb links?  And then does it repeat those back and forth or does it show 5 more females, etc? And if so, what happens when we run out of records or have more of one gender than the other?

I'm thinking the easiest would be to show a big list of links grouped by 5 of each gender until we have less than 5 of each gender and then stop.  Would that work? 

Dave Edis - Senior Developer
interactivetools.com

By Codee - February 13, 2014

the html code above doesn't state?  Right now it shows 1 row, 5 photos/links, either all female, or all male...and it rotates the single row every 2 seconds or so. So we "see" in the browser 5 female, then 5 male, then 5 female, then 5 male, etc.  It's easy and has been working that way for couple years.  What she wants it to do is show in 1 row at a time: female | male | female | male | female...so basically every 1 row shows as girl-boy-girl-boy-girl ?  Does that make more sense?