Help please…
I have 2 sections
- Products – which lists all of the products – called products.php ($productsRecord)
- Categories – basically, some brief intro to each category, and a series of generic header images for each category.
Within products, each product is assigned to a category (a drop down from a list linked to the categories), and a respective category image is assigned as the header (limit 1, random shuffle)
Where I am stuck is assigning the category “on the fly” rather than having to create a different product page for each category. I am currently using this:
// load record from 'categories'
list($categoriesRecords, $categoriesMetaData) = getRecords(array(
'tableName' => 'categories',
'where' => ' title="Janitorial" ',
'orderBy' => 'RAND()',
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$categoriesRecord = @$categoriesRecords[0]; // get first record
if (!$categoriesRecord) { dieWith404("Record not found!"); } // show error message if no record found
But is there a way to generate this dynamically?
Where I am trying to insert this is somewhere in the below section if possible, rather than having to rely on ' 'where' => ' title="Janitorial" ', - is this possible?
<!--*-*-*-*-*-*-*-*-*-*- BOOTSTRAP CAROUSEL *-*-*-*-*-*-*-*-*-*-->
<div id="bg-img"><?php shuffle($categoriesRecord['banner_image_upload']) ?><?php foreach ($categoriesRecord['banner_image_upload'] as $index => $upload): ?> <?php if($index >= 1) { continue; } // limit uploads shown ?>
<div class="parallax-bg pad-t-150 pad-b-150 pad-section-50 overlay-dark" style="background-image:url(<?php echo htmlencode($upload['urlPath']) ?>)"
data-center="background-position: 50% 0px;"
data-top-bottom="background-position: 50% -100px;"
data-anchor-target="#bg-img">
<div class="parallax-container">
<div class="parallax-content"
data-206-top="opacity: 1"
data-0-top="opacity: 0"
data-anchor-target="#bg-img h1">
<h1 class="text-uppercase txt-dark"><?php echo htmlencode($productsRecord['title']) ?></h1>
<p class="txt-dark"><?php echo htmlencode($productsRecord['subhead']) ?> | <?php echo $productsRecord['category'] ?></p>
</div>
</div>
</div> <?php endforeach ?>
</div>
<!--*-*-*-*-*-*-*-*-*-*- END BOOTSTRAP CAROUSEL *-*-*-*-*-*-*-*-*-*-->
The category title (eg. Janitorial) works as a drop down, but if I add a link for banner_image_download from the gallery section I get a fatal error?
Thanks in advance
Cheers
Carole