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 ross - April 14, 2017

Hi Tim

Could you post a copy of the whole file so I can see your code in context?  

Feel free to email it to me directly if you don't want to have it online in our forums.

Thanks!

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

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