Viewer Detail page with multiple category outputs and styles

4 posts by 3 authors in: Forums > CMS Builder
Last Post: April 29, 2010   (RSS)

By mark99 - April 27, 2010 - edited: April 27, 2010

I've created a new section (big_animals) and in it I have a field called 'category' (contains a checkbox list of options like 'big_cats','big_frogs' etc.), among many others.

Now I've also created several listing viewer pages, each with specific calls to a certain category option and different templates for the output of different fields. I select the category for each viewer file by this simple method (on the listing viewer page that is, obviously the detail viewer might have problems doing the same):

'where' => " category LIKE '%big_cats%' ",

Works fine, but I only have a single viewer detail page (as is my intention). Now I'd like to output several categories and related fields on to the detail.php page, each having their own unique fields and styles. Crucially I only want to output the data for categories that actually apply to any given record, so as to avoid confusing people with lots of blank fields for categories that might not apply to my product. If you see what I mean :). Anyway I have no idea how to do this.

It would be wonderful if my Detail page only showed data for related categories.

Re: [ross] Viewer Detail page with multiple category outputs and styles

By mark99 - April 29, 2010 - edited: April 29, 2010

Yes but then that will only output the data for a single category when I want the Detail page to be a summary of all categories.

Re: [mark99] Viewer Detail page with multiple category outputs and styles

By Jason - April 29, 2010

Hi,

So you want to have a single detail page that outputs information for all of the different categories, but each category will output different fields. Is that right?

If so, you could have a different database select for each of your categories. For example:

list($bigCatsRecords,$bigCatsMetaData)=getRecords(array(
'tableName'= 'products',
'where'=> "category LIKE '%big_cats%'",
));

list($bigFrogsRecords,$bigFrogsMetaData)=getRecords(array(
'tableName'= 'products',
'where'=> "category LIKE '%big_frogs%'",
));

...etc


Then you would individually output each of those in a separate loop. Example:

<?php foreach ($bigCatsRecords as $record): ?>
*OUTPUT FOR BIG CATS*
<?php endforeach ?>


<?php foreach ($bigFrogsRecords as $record): ?>
*OUTPUT FOR BIG FROGS*
<?php endforeach ?>

...etc


Does that sound like what you're aiming for? Let me know.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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