Ignore Category Filter

11 posts by 2 authors in: Forums > CMS Builder
Last Post: April 20, 2011   (RSS)

Re: [Perchpole] Ignore Category Filter

By Jason - April 18, 2011

Hi Perch,

So on your page you're getting a list of categories and a list of records, but you're finding that when you select a category, you're only seeing records associated with that category and you still want to see them all. Is that right?

If so, my guess would be that when you're selecting a category, a "category" variable is being put into your URL. This is probably causing your getRecords call to put the category into it's "WHERE" clause. The easiest solution here would be to put the:
'allowSearch' => false,
option into your getRecords call.

Hope this 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] Ignore Category Filter

By Perchpole - April 18, 2011

Hi, Jason -

Thanks for your input...

Your suggestion is just what I thought the answer would be. The trouble is, when I use...
'allowSearch' => false,
...I can't then run a search on the page - which is exactly what I'm trying to do!

Doh!

:o/

Perch

Re: [Perchpole] Ignore Category Filter

By Jason - April 18, 2011

Hi Perch,

In that case, what I would do is use 'allowSearch' => false, and then build up your own "WHERE" clause to do the search, that way you control exactly which fields are part of your search.

Hope this 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] Ignore Category Filter

By Perchpole - April 18, 2011

Hi, Jason -

I've got into a pattern of building sites (with CMSB) which rely heavily on the category hierarchy. That way, much of the data I pipe into each page can be executed via some kind of $selectedCategory statement.

It's neat and modular.

The only issue I've come across is when trying to create an Archive page. This would be a category just like any other - but without any records assigned directly to it.

The issue is how to pull the records in via various date searches and the like.

If the "WHERE" clause overrides the category hierarchy then there should be some way of filtering the entire pool of records according to the search criteria?

:oS

Perch

Re: [Perchpole] Ignore Category Filter

By Jason - April 19, 2011

Hi Perch,

From the sounds of it, the problem you're experiencing is only happening when CMS Builder is automatically doing the search for you. Setting 'allowSearch' => false, just means that CMS Builder won't do the search for you, you can still manually construct your own where clause.

If you could provide me an example of the page where you're having a problem along with what type of search you want to perform, I should be able to help.

Thanks
---------------------------------------------------
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] Ignore Category Filter

By Perchpole - April 19, 2011 - edited: April 19, 2011

Hi, Jason -

Thanks for your help.

The search format is something like this...

./index.php?category=n&createdDate_year=nnnn&createdDate_month=nn

I've tried constructing my own WHERE clause but it doesn't [seem to] work with the extended search suffixes, i.e. _month and _year.

Is there a way around this?

:0)

Perch

Re: [Perchpole] Ignore Category Filter

By Jason - April 20, 2011

Hi Perch,

Here's another option. Instead of creating our own WHERE clause and using 'allowSearch', we could just temporarily remove category from the $_REQUEST variable.

For example:

<?php
$tmpCategory = @$_REQUEST['category'];
$_REQUEST['category'] = "";

list($articleRecords, $articleMetaData) = getRecords(array(
'tableName' => 'articles',
));

$_REQUEST['category'] = $tmpCategory;
?>



Hope this 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] Ignore Category Filter

By Perchpole - April 20, 2011

Hi, Jason -

Hmmm. I really need to maintain the $_REQUEST['category'] relationship as this controls almost all of the switches on the page template. By defining the category I can control which documents to insert, which side-bar widgets to display - as well as providing the site-wide navigation system with a direct link to self.

The only thing I can't do easilly is run a search at the same time!

Bah!

:0/

Perch

Re: [Perchpole] Ignore Category Filter

By Jason - April 20, 2011

Hi Perch,

The code I posted does maintain it. It assigns the value to a temporary variable, empties category out of the $_REQUEST array, performs the query and then puts the value for $_REQUEST['category'] back. So the only thing this will affect is that one query, everything else will have access to that variable.

Hope this 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/