Big Question

5 posts by 2 authors in: Forums > CMS Builder
Last Post: March 31, 2010   (RSS)

By DanMaitland - March 29, 2010

Ok I have a big question. So I am creating this website for a wine distributor. They will have one multi section for wines where they will enter in all their wines with the info that goes along with it like Name, description, year, vintage, price, PRODUCER etc...

Then they will have another multi section for PRODUCERS with all the info required like Name, description, region, logo etc.... Now they won't have a detail page for the wine just a list and the Producers section will have both a list of producers and their respective details page. Now the big question is, when entering in a new wine is there a way that the user can select a producer from some sort of list so that on the PRODUCERS details page along with all the PRODUCER'S info we can display all the wines that are linked to that specific PRODUCER.

I really hope that I am being clear enough. I have a decent grasp of CMS Builder but am by no means a PHP master. Is there a semi simple way of doing this or some sort of work around. I have already used Chris's elatedlookup plugin and have acheived 90% of what I needed it to do but was wondering if there is another way to get this to work or if Chris's plugin can help me with this project.

Re: [Dan Maitland] Big Question

By Jason - March 30, 2010

Hi Dan,

One way to do this is to add a field in the "wine" section called producer. Make it a list field. Under list options, select "Get options for database". Select you "producers" table, select "num" for the values, and "title" for the labels.

Now when you go to add a wine to the wine section, there will be a dropdown with all producers.

Finally, in your Producer list or display page, you can use the following code to display all the wines they are associated with:

<?php
list($wineRecords,$wineMetaData)= getRecords(array(
'tableName' => 'wine',
'where' => 'producer='.$record['num']
))
?>
<?php foreach($wineRecords as $wine): ?>
<?php echo $wine['title'] ?>,<?php echo $wine['year'] ?><br />
<?php endforeach ?>


You'll have to adjust the names based on how you've named things. But this will list the wines associated with a given producer.

Let me know if that helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Big Question

By DanMaitland - March 31, 2010

Jason,
Are you sure there isn't supposed to be an if statement in there somewhere? From the looks of the code I think that will just call all wines and not just the ones associated through the list. I could definitely be wrong but it just doesn't look right for some reason.

Re: [Jason] Big Question

By DanMaitland - March 31, 2010

KILLER!! I'll try it out and let you know. Thanks J.