Categories and records grouped on same page

17 posts by 4 authors in: Forums > CMS Builder
Last Post: May 13, 2009   (RSS)

I have a multi record page that displays categories and records under each category. These are all on the same page. In the admin I created a List Option that contains the categories. This way, each record can be assigned multiple categories. I was able to get it to work using this code from another post:
<?php if ($record['category'] != @$lastCategory): ?>
<?php $lastCategory = $record['category']; ?>
<h1><?php echo $record['category'] ?></h2>
<?php endif ?>

But the problem I am having is that, on the viewer page, the categories are being grouped together whenever a record has more than one category assigned to it. I want to be able to show each category separately and multiple instances of a record if it exists in various categories.

Re: [sparks] Categories and records grouped on same page

By Dave - February 25, 2009

Hi sparks, welcome to the CMS Builder forum! :)

That ones a little tricky and requires a bit of custom code. Can you attach your section schema file (found in cmsAdmin/data/schema/yourSection.ini.php) and your viewer file? (Attach them to the post, don't copy and paste their contents into the message).

I'll see if I can write up something that will work for you.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Categories and records grouped on same page

Thanks for the help. You guys are the best. I've been using your cms for over a year now and this is the first time I need something that isn't built in. I am attaching the files. I appreciate the help.

Re: [ross] Categories and records grouped on same page

Great. I am almost there. The code has created the categories and records correctly. Now, how do I link each record to its detail page?

Re: [sparks] Categories and records grouped on same page

By ross - March 2, 2009

Hi.

To get the articles linking, you would need to change this line of code:

if ($isRecordInCategory){ $rows .= $record['title'] . "<br/>";}

Try replacing that with this:

if ($isRecordInCategory){ $rows .= "<a href='" . $record['_link'] . "'>$record['title'] . "</a><br/>";}
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] Categories and records grouped on same page

By 28sparks - March 3, 2009

Ross:

The code did not work. The page no longer loads. Any ideas?

Thanks.

Re: [sparks] Categories and records grouped on same page

By Dave - March 4, 2009

Sparks,

Try this instead:

if ($isRecordInCategory){ $rows .= "<a href='{$record['_link']}'>{$record['title']}</a><br/>"; }
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Categories and records grouped on same page

By 28sparks - March 4, 2009

You guys are the best. It worked perfectly. This is the type of support that makes your product so valuable. I would have had to pay a programmer several hours of work to figure this out. Instead, I think I'll spend that money on some new CMS Builder licenses. Thanks again.

Re: [ross] Categories and records grouped on same page

By petejdg - May 4, 2009 - edited: May 4, 2009

Ross,
I am trying to do almost the same thing. I created a category with two staff sections, then records under each staff section. I would like to show the first category section with the records and then the next category with records. I tried to use the code you provided and tweak to make it work for me but I cannot get anything to show. I thought maybe I could make it work for me....
can you look at see what i need to make it work?
(I guess my list is just a dropdown and wouldn't have to check against multiple categories....)

Thanks,
pete
Attachments:

our_staff-ini.php 3K