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: [kovali] Top Level Categories and products

By _kate_ - October 16, 2008

Hi again,
In regards to your second question:

Viewer URL
The address of a page used to load records from a Section Editor. There are separate Viewer URL's for your List Viewer pages and Detail Viewer pages. Viewer URL's should point to a page on your server that has been set up with either List Viewer or Detail Viewer code from CMS Builder's Code Generator.

Say for example I have made a multi list section called "Juices", generated the List Page code and saved it in a page called "juices.php". You want visitors to be able to view the details of each juice so you also generate a detail page and call it "juice_detail.php". By specifying the URLs in CMS Builder you are telling it where it can find the information it needs - so if someone goes to "juice.php" and clicks on a juice it knows to use "juice_detail.php" to display the detail info and vice versa.

I hope that helps... maybe someone else can explain it a little better :)

If you have any other questions feel free to ask :)