filtering results at point of listing

3 posts by 2 authors in: Forums > CMS Builder
Last Post: July 19, 2018   (RSS)

By willydoit - July 11, 2018

Hi all,

I have a customer database covering many different types of services that they provide. 

I have a page where I want to display a number of carousels showing images of the clients business. I want to filter these carousels by virtue of the services supplied, ie if the client is an accommodation provider they will be shown in one carousel, if they are an attraction they will show in a seperate carousel.

My question therefore is how do I filter the records at the point of listing, I got things working if I filter the services in the header with 

'where' => ' `services_provided` LIKE "%Accommodation%" and `listing` LIKE "%Featured%"',

But this means other service types aren't loaded into the array.

My code for one of the carousels is currently

<ul class="amazingcarousel-list">
            <?php foreach ($advertisersRecords as $record): ?>
             <?php foreach ($record['images'] as $index => $upload): ?>
             <?php if ($upload['hasThumbnail']): ?>
          <?php if ($index >= 1) { continue; } // limit uploads shown ?>
                <li class="amazingcarousel-item">
                    <div class="amazingcarousel-item-container">
                   
<div class="amazingcarousel-image"><a href="<?php echo htmlencode($upload['thumbUrlPath3']) ?>/" title="<?php echo htmlencode($upload['info1']) ?>" ><img src="<?php echo htmlencode($upload['thumbUrlPath3']) ?>"  alt="00s" /></a></div>
<div class="amazingcarousel-title"><?php echo htmlencode($record['title']) ?></div>

                    </div>
                </li>
                <?php endif ?>
                <?php endforeach ?>
                <?php endforeach ?>
            </ul>

I assume that I somehow need to add the where clause  shown above into the foreach element but I dont know the syntax required to achieve this.

The ultimate result will be six different carousels containing different content based on the value of services_provided.  I will need to include an or element as for food it me baty that I need services_provided = cafe or restaurant or take away etc

Thanks in advance for any help provided.

By willydoit - July 19, 2018

Thanks Leo, all working now.