Need if then statement for filtering

4 posts by 2 authors in: Forums > CMS Builder
Last Post: March 14, 2017   (RSS)

By dccreatives - March 13, 2017

I have a page that has downloads based on the brand. Each item in the brand has different downloads. It is a lighting company that has a brand family, items of that family and each item has downloads.

Now I have some items available for quickship. I want the items of each brand to have the quickship pdf download to show on a page.

http://www.axislighting.com/CMS/downloadsList-qs2.php?brand=Beam4%20LED

This Brand Beam4 has quickship, but only for some item styles like in this instance the Recessed. But on that page it is showing all the items under this family whether there is a download or not. Can i write a statement to show only the items of brand that have the download? Here is my file. Basically, I want that if there is no download then it shouldnt show that item.

Attachments:

downloadsList-qs2.php 5K

By ross - March 13, 2017

Hi there.

Thanks for posting.

What I'd like to start out with is confirming that you are actually uploading the PDF's to records in your "brands" section.

I see that you load that at the top of your page ($brandsRecords).

If I am on the right track here, the logic will be something along these lines:

<?php foreach ($brandsRecords as $brand): ?>
<?php if ($brand['pdf']): ?>
DISPLAY DOWNLOAD LINK
<?php endif ?>
<?php endforeach; ?>

Keep in mind that this is a really basic overview of the code you'll need to use so there will likely be adjustments.

Do you at least get the idea of what I am aiming or here?

Basically, I am looping through each record from the "brands" table and seeing if a file has been uploaded to it.  Note that I am assuming your upload field is called "pdf".

Let me know any questions.

Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

By dccreatives - March 14, 2017

Thanks. I worked with the code and it works perfectly. After I called all the records. I added the extra if statement as if the record has a quickship, it should show and that worked nicely. I dont have all the extra products only the ones with the record. Thanks.