Pagelist thumbnail
Permalink 1 user found helpful
I am creating a page-list of thubnails, much like this:http://mattgreydesign.com/projects/... however I would like every 3rd thumbnail to have a different class so the padding aligns them properly, how would I go about doing this using my existing code? ....
Much appreciated
<div class="ccm-page-list-3"> <?php for ($i = 0; $i < count($cArray); $i++ ) { $cobj = $cArray[$i]; $title = $cobj->getCollectionName(); ?> <div class="ccm-page-list-itm-3"> <h3 class="listheader-3"><a href="<?php echo $nh->getLinkToCollection($cobj)?>"><?php echo $title?></a></h3> <div class="ccm-page-list-description-3"> <?php if($cobj->getAttribute('thumbnail')): ?> <?php endif; ?> <?php if(!$controller->truncateSummaries){ echo $cobj->getCollectionDescription(); }else{ echo $textHelper->shortText($cobj->getCollectionDescription(),$controller->truncateChars);
Viewing 15 lines of 34 lines. View entire code block.
Much appreciated
Ill give it a try, I thought it would use an array but I'm not that good at this type of thing...
Worked like a charm, simple but effective, been trying to work it out for ages, thanks :~)
No worries, glad it helped :)
You can set up a variable to store an output count so that for every third iteration of the loop that outputs your thumbnails you can output a different class to the div.
Outside of the loop declare the variable, then within the loop increment and check its valu, either output the default class, or the alternative class and reset the counter.
The output count is $outputCount, for the third loop the class 'additionalClass' is used.
Amended code:
Not tested, so please ensure you check and test code before deploying to a live environment, take a backup of the existing file.
Hope this helps,
Charlie.