4 posts by 3 authors in: Forums > CMS Builder Community
Last Post: August 24, 2016   (RSS)

Hi There,

I am not sure what way this should be put in. I am looking to add in a CSS element for the last list item. Can anyone let me know how to do this? The code that I want to enter is "last" in the div's class "<div class="col-1-5">" (highlighted within ***************)

My code is:

// load records from 'club_sponsors'
  list($club_sponsorsRecords, $club_sponsorsMetaData) = getRecords(array(
    'tableName'   => 'club_sponsors',
    'limit'       => '5',
    'orderBy'     => 'RAND()',
    'loadUploads' => true,
    'allowSearch' => false,
  ));

 <?php foreach ($club_sponsorsRecords as $record): ?>
                       <?php foreach ($record['company_logo'] as $index => $upload): ?>
                                ***************<div class="col-1-5">***************

                                             <a href="<?php echo htmlencode($record['website']) ?>"><img src="<?php echo htmlencode($upload['thumbUrlPath']) ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="<?php echo htmlencode($record['title']) ?>" /></a>

                                </div>
                       <?php endforeach ?>    
<?php endforeach ?>

                <?php if (!$club_sponsorsRecords): ?>
                  No records were found!<br/><br/>
                <?php endif ?>
                                  </div>

By Toledoh - August 23, 2016

Try playing around with the css selector of :last-child or :last-of-type.  something like this may work

<ul id="sample">

<?php for each... ?>

<li>Output goes here...</li>

<?php endforeach ?>

</ul>

- - - -

#sample li:last-of-type { colour: red;}

Cheers,

Tim Forrest
Toledoh Enterprises
www.toledoh.com.au

Thanks Daryl!