Category issue

6 posts by 3 authors in: Forums > CMS Builder
Last Post: February 2, 2010   (RSS)

By DanMaitland - January 30, 2010

Ok bear with me here and I will try and explain this as best I can.

We are building a website for a wine distributor. they have one section called producers which when clicked brings you to a list page that shows all the producers logos with a short description. When the user clicks on a specific producer they are brought to a details page where it displays a full description with various details about that specific producer.

Pretty straight forward so far.

Now when the user is on the producers detail page we also want to see a list of wines that are associated to that specific producer. if a wine has been selected from that list they will then be brought to another detail page for that specific wine with all its details.

so in essence there would be a multi list section or category section for the producers with a detail page for each producer and then another multi section or category section for the list of wines.

Our problem is that we don't know how to associate the wine list to the producer so that when the producers detail page is brought up it will show a list of wines associated to that particular producer.

Is there a way that two different sections can be linked or associated with one another. Maybe you guys have another solution for us.

I really hope that I am explaining my self clearly.

Re: [Dan Maitland] Category issue

By DanMaitland - January 31, 2010

Ok so I am able to set it up so that I can have a list menu in appear when creating a new wine record and it will let me choose any producer that I have already entered. Great.

But what I don't get is how do I now create a details page for a producer and have it also show only the wines that are associated to that particular producer. I know it must be possible but I just don't see it. Please if anyone can give me a more detailed explanation it would be greatly appreciated.

Re: [Dan Maitland] Category issue

By DanMaitland - January 31, 2010

Please, can someone help me to get this working. The site I'm building depends on this small but important function.

Re: [Dan Maitland] Category issue

By flamerz - February 1, 2010

Hi again.

in your details page you will have the wine producer and his wines.

you can generate the wines list from the cms.

but, to show each wine and its details, you have to load this way:

$winearray = getListValues('producers', 'wine', $producersRecord['wine']);
$wineascsv = join(', ', $winearray);

list($winesRecords, $winesMetaData) = getRecords(array(
'tableName' => 'wines',
'where' => "num in (0, $wineascsv)",
));

first is get the tab separated field and convert to comma separated values, and second is assemble the query.

after this you can echo it:

<?php foreach ($winesRecords as $record): ?>
Name: <?php echo $record['name'] ?><br/>
Content: <?php echo $record['content'] ?><br/>

<?php endforeach ?>


i hope you can get the way to do, sorry if i did some bug in the code. (i hope not, but im traveling and just writing from my small laptop in hotel). [pirate]

Re: [Dan Maitland] Category issue

By Chris - February 2, 2010

Hi Dan,

But what I don't get is how do I now create a details page for a producer and have it also show only the wines that are associated to that particular producer.


Are wines associated with one producer or can they be associated with more than one producer?

I'm going to assume that each wine is made by one producer. Please let me know if this is not the case and I'll show you how to solve that problem.

You can use a "where" clause to load only the Wine records which have their producer field set to the producer you're showing:

list($producersRecords, ) = getRecords(array(
'tableName' => 'producers',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$producerRecord = $producerRecords[0];
list($wineRecords, ) = getRecords(array(
'tableName' => 'wine',
'where' => 'producer = "' . mysql_escape($producerRecord['num']) . '"',
));


If you aren't sure how to to integrate this code, please post the full PHP source code of your producer detail page and I'll show you what to change.

I hope this helps! Please let me know if you have any questions.
All the best,
Chris