Category issue

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

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 flamerz - January 30, 2010 - edited: January 30, 2010

I think you can do a wines table (category type), and insert a pulldown multivalue field in your multicategory table of wine distributors to set eachwine that producer has.

in the multicategory set "get options from database", database "wines", option values: num and option labels: name.

You have a nice tutorial about categories in this forum.

wine producers
title textfield
Content wysiwyg
Wines (ctrl+clic) list *

wines
title textfield
Content wysiwyg

* this one set as multicategory

Re: [Dan Maitland] Category issue

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

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 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