Question About Sub Categories and Filtering / Sorting via URL

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

By Rusty - February 24, 2011 - edited: February 24, 2011

I ask because I'm not sure how to phrase my searching on this one.

This is an example.

Section Editor, List Page for Blog, with blog.php as list view, and blog-detail.php as detail view.
Within the Blog Section Editor I have a Field Label, and Field Name of "Category", with a Field Type of "List" displayed as "Check Boxes (Multi Value)" with the List Options as "Get options from database (Advanced )".

This list or check boxes pulls its values from another Section Editor, list page with "Blog Categories" and the only thing it has is a Title text field.

So.. the Blog Section Editor, populates the Category Check Boxes from the Blog Categories Section Table Name, with the Title for the Label and the Values.
Let's say the categories are News, Sports, & Weather.

I realized late last night that I don't know how to properly filter the sub categories. I know I can filter them if I manually code in Checkboxes as News, Sports, and Weather, however I really like the idea of being able to provide dynamic category population and filtering.

For example, hard coded check boxes filter just fine with this bit of code:

This works for hard-coded, non-dynamic checkboxes
// load records
list($blogRecords, $blogMetaData) = getRecords(array(
'tableName' => 'blog',
'where' => 'news',
'perPage' => '5',
'allowSearch' => '0',
));

This works for hard-coded, non-dynamic checkboxes


However if the Category check boxes are populated via the database from another table, it doesn't seem to work. I did find a few posts that I think were talking about trying to do more or less the same idea with the old Article Manager, but I'm not sure.

Does anyone have ideas where to start on this?

I enabled MySQL Debugging and this bit of code I was trying just tells me that "No Records were found"

This doesn't work, where I'm trying to filter by dynamically populated subcategory
(By dynamically populated, I mean the options in the section editor, not the filtering bit, I have no problem making that hard coded to a page)
// load records
list($blogRecords, $blogMetaData) = getRecords(array(
'tableName' => 'blog',
'where' => 'category = news',
'perPage' => '5',
'allowSearch' => '0',
));

This doesn't work, where I'm trying to filter by dynamically populated subcategory



[font size=4]And secondly....
I know there is a way to perform simple searching / filtering / sorting via URL, but for the life of me can't remember how to do it.

I want to try and do the easy way of not having to make a hard coded section that declares the 'where' => 'category = news', and parse it with a URL search.

I have done this before, but for the life of me can't remember how to get it to work. It was something like this:

http://www.mysite.com/blog.php?category=news and since it was a link, when the user clicked on it, it auto-magically filtered all the blog posts with News sub category checked. It is quicker and easier than having to hard code the loading of records.

That being said, anyone remember how to do it properly? And does anyone see any reasons why I wouldn't want to do things that way?

Thanks in advance, I really love this CMS..., and the amazing support we have in the small community of coders & IAT staff.
Rusty

Re: [Jason] Question About Sub Categories and Filtering / Sorting via URL

By Rusty - February 25, 2011

Thanks so much Jason, I'll give that a try! For some reason looking at that now, it looks so familiar, and I can't figure out why I didn't try that earlier. Probably a mental block from too much caffeine.
Rusty