getPrevAndNextRecords() - Hidden Records?

10 posts by 4 authors in: Forums > CMS Builder
Last Post: February 2, 2015   (RSS)

Just a quickie...

Does getPrevAndNextRecords() observe the hidden record status? If so, is there any way to turn it off?

Thanks,

Perch

By claire - February 2, 2015

Just checked the codebase for CMSB to be sure, but as far as I can see it ignores the hidden record flag.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Hi, Claire -

That's interesting. I've done a couple of tests and my prev/next pagination gets flaky when a page is "hidden". Perhaps it's the data I'm feeding into getPrevAndNextRecords()? My code looks like this:

$optionsArray = array(
    'tableName' => 'pages',
    'where' => " parentNum = '".intval($selectedPage['parentNum'])."' ",
    //'where' => " parentNum = '".intval($selectedPage['parentNum'])."' && hidden != 1 ", /*Alternative*/
    'recordNum' => $selectedPageNum
);  
  
list($prevRecord, $nextRecord, $firstRecord, $lastRecord) = getPrevAndNextRecords($optionsArray);

What does getPrevAndNextRecords() need from the array in order to work properly?

:0/

Perch

By claire - February 2, 2015

That '&&' should be 'AND'. The double ampersand logical operator isn't supported in MySQL, as far as I know.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Hi, Claire -

Thanks for the tip - but it still doesn't work.

Here's the thing, if I filter out hidden records - using this where statement...

'where' => " parentNum = '".intval($selectedPage['parentNum'])."' AND hidden != 1",

...it works fine.

However, if I don't filter out the hidden records...

'where' => " parentNum = '".intval($selectedPage['parentNum'])."' ",

...the prev/next sequence breaks.

Something somewhere is tripping over hidden records.

Perch

By Damon - February 2, 2015

Hi Perch,

How about just using this code to override and show hidden records:

'ignoreHidden'      => true,  // don't hide records with hidden flag set

Let me know if this does what you need.

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Hi, Damon -

I didn't know I could add that to the $optionsArray. I assumed it was for getRecords() calls only?

Perch

By Damon - February 2, 2015

I didn't know I could add that to the $optionsArray. I assumed it was for getRecords() calls only?

Sorry, I use this for getRecords, missed the $optionsArray part. Don't think this will work in this case.

Still looking into this.

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By claire - February 2, 2015

I think I might know what's going on here.

getPrevAndNextRecords() depends on a call to getRecords() after it determines which records it needs. That call uses some default settings, meaning it DOES actually drop all hidden records. There's no way to turn it off that I can see. The getPrevAndNextRecords code fails after that point because it expects a particular record that isn't returned by the getRecords call.

Maybe Dave or Damon can confirm if I have this right?

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/