Top Level Categories and products

4 posts by 2 authors in: Forums > CMS Builder
Last Post: October 16, 2008   (RSS)

By kovali - October 16, 2008

Hi,

I've created an editor (Menu Type = Category Menu) to show a list of products in a website. There are about 6 Top Level Categories which all contain about 10 products each. For example:

Juices
- Orange Juice
- Apple Juice
- Tomato Juice
- ...

Wines
- Bourdeaux
- Champagne
- White wine
- ...

Is there a way to link to a Top Level Category that will show only this Top Level Category and all the products it contains ? I tried the MySQL "where" (and also "Like") clause but this doesn't same to work well for me. See my code below pls, i used a selectbox $record['type_categorie'] to be able to use different css styles to Top Level Category title and it's products.


<?php

require_once "/home/vosab/public_html/beheer/lib/viewer_functions.php";


list($assortimentRecords, $assortimentMetaData) = getRecords(array(
'tableName' => 'assortiment',

'where' => 'name LIKE "%Wines%" or name LIKE "%Bourdeaux%" or name LIKE "%Champagne%" ', ));


?>

<h1>Assortiment - List Page Viewer</h1>
<?php foreach ($assortimentRecords as $record): ?>

Productgroep: <?php echo $record['parentNum'] ?><br/>
Benaming: <?php echo $record['name'] ?><br/>
Type categorie: <?php echo $record['type_categorie'] ?><br/>
Omschrijving (NL): <?php echo $record['content'] ?><br/>

<?php foreach ($record['foto'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>


<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>


<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>


<?php endif ?>
<?php endforeach ?>



<?php foreach ($record['pdf'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>


<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>


<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>


<?php endif ?>
<?php endforeach ?>
<!-- STEP2a: /Display Uploads -->



<hr/>
<?php endforeach; ?>


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


Second (general) question: I don't understand the function or meaning of "Viewer Urls"... what is this used for? Example ?

Thanks !!

Re: [kovali] Top Level Categories and products

By _kate_ - October 16, 2008 - edited: October 16, 2008

Hi kovali,
I'm not sure using a Category Menu is the best method to achieve what you want to achieve.

I've been listing products by type a lot lately and find the below method works quite well. The way I approach it is by making my main product a multi list section (so for example Juices) and then making a list field within it called "Type" or something similar (the types would be Orange Juice, Apple etc).

If you want to display the entire product listing for your top level category, then you simply use the code generated for that products section which will display them all - use the List Page code.

If you want to display sections by Type, you can now do so by adding the red line of code below to the standard List Page code outputted by CMS Builder as shown below.
"type" will need to match the name of your list field, and "Orange" will need to match the type you want to display.

<?php foreach ($juicesRecords as $record): ?>
<?php if ($record['type'] != "Orange") { continue; } ?>

I hope that was helpful. If you have any more questions please don't hesitate to ask :)

Re: [_kate_] Top Level Categories and products

By kovali - October 16, 2008

Thx for the advice Kate, will try it your way.

CMSB is new to me and i must say i'm very happy with all the possibilities, very impressive. I understand that it's near to impossible to write a manual for it, but a 'knowledge base' or 'faq' could be interesting, instead of having to dive into the forum posts every time ;-)

Thanks again.