Conflict with 'allowSearch' => false,

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

By Toledoh - April 13, 2017

Hi Guys.

I've got a page that is listing "panels"


list($panelsRecords, $panelsMetaData) = getRecords(array(
'tableName' => 'panels',
'where' => 'pagesNum='.$selectedCategory['num'],
'loadUploads' => true,
'allowSearch' => false,
'leftJoin' => array('includes' => 'include'),
));

Some of those panels is displaying google map records

// get records
list($myRecords, $myMetaData) = getRecords(array(
'tableName' => $GLOBALS['GEOCODER_SAMPLE_TABLENAME'],
'allowSearch' => true,
));

However, the maps are only showing a single result, and I'm thinking that it's due to the original 'allowSearch' => false even though I've applied true to the myRecords...

If I change the original to true, I get the error.

MySQL Error: Column 'num' in where clause is ambiguous

Any ideas?

Cheers,

Tim (toledoh.com.au)

By gregThomas - April 17, 2017

Hey Tim,

My guess is that you're using the permalinks plugin on this page? If so, the issue is most likely to be that the permalinks plugin artificially sets the page num value in $_REQUEST['num']. Then when you set allowSearch to true, the page is only trying to load records that have the num value of the permalink. 

The simplest way around this is to add the following to your code:

//If the permalinks plugin has set the num value in the request, unset it.
if(isset($_REQUEST['num'])) { unset($_REQUEST['num']); }

//Load the panel data
list($panelsRecords, $panelsMetaData) = getRecords(array(
  'tableName'   => 'panels',
  'where'       => 'pagesNum =' .$selectedCategory['num'],
  'loadUploads' => true,
  'allowSearch' => false,
  'leftJoin'    => array('includes' => 'include'),
));

This will detect if the num has been set by the permalinks, and unset it before the getRecords function runs.

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By Toledoh - April 17, 2017

That works - thanks Greg!

Cheers,

Tim (toledoh.com.au)