hiding records from multi-search

11 posts by 2 authors in: Forums > CMS Builder
Last Post: May 9, 2019   (RSS)

By craig_bcd - May 8, 2019

Hi -

I have a checkbox field in my section (do_not_display) and I want to exclude any record that is checked from the search results.  I  already found (unsuccessfully) you cannot use a where clause and I found another archived entry which frankly I just didn't understand (perhaps I need more coffee today).

Below is the search code for that table, I can attach the page code if you think that would help but I can't figure out how to exclude these records marked as do_not_display.

$searchTables['x_leadership_sales'] = array(
'viewerUrl' => 'about-leadership.php',
'titleField' => 'title',
'summaryField' => 'content',
'searchFields' => array('title','content'),
);

Thanks!

Craig

By Deborah - May 8, 2019

Hi, Craig.

You might try this...

<?php foreach ($searchRows as $record): ?>
<?php if ($x_leadership_salesRecord['do_not_display'] == "0"): ?>
   (search results list)
<?php endif ?>
<?php endforeach ?>

~ Deborah

By craig_bcd - May 8, 2019

Hi Deborah - 

Thank you, it works functionally but there is one caveat, the numeric result lists then don't function correctly.  Say for example I type in a name that I know is in do not display, it tells me there is 1 record in my result but of course because of the code, the record does not display (this is the good part).

I was hoping to exclude it farther up in the process so the results numbers are accurate. 

Thanks again!

By Deborah - May 8, 2019

Hmm. I hadn't considered that.

Maybe this post will help:
https://www.interactivetools.com/forum/forum-posts.php?postNum=2236436#post2236436

~ Deborah

By Deborah - May 8, 2019

Craig,

I've not tried this myself, but am interpreting that it might work for you to rename your 'do_not_display' field to 'ignoreHidden', which appears to be a special fieldname within CMSB.

If that doesn't work, post back and perhaps someone else can provide a working solution.

~ Deborah

By craig_bcd - May 9, 2019

Hi Deborah - 

Thank you again, but unfortunately it did not work -   when i put that in I get a 500 series error (see attached).  

Thanks again.

Craig

Attachments:

ignoreHidden-error.JPG 34K

By Deborah - May 9, 2019 - edited: May 9, 2019

Craig, maybe the field should be named 'hidden' or 'Hidden'.

Sorry, but I've never used that feature before. Perhaps someone else can chime in.

~ Deborah

By craig_bcd - May 9, 2019

Hi Deborah - 

I had the same thought this am - the section editor does indeed indicate that "hidden" is a special field type but the 'ignoreHidden' => true,  statement still causes a 500 error on the page. I feel like we are close but there is some (critical) piece of information I am missing.

Thanks

Craig

By craig_bcd - May 9, 2019

Well...now I feel dumb....

After reading some more entries in the forum about "hidden" records and how they behave I discovered the interactive tools (not surprisingly) guys already thought of this.  if you use the "hidden" field as the checkbox in your section editor to hide fields you don't have to do anything in the search array to exclude these hidden records, it happens automatically.

By setting this:'ignoreHidden' => true,  I was actually doing what I did not want to do which was to ignore that hidden field and show the record...some days...

If others have this issue, as long as you use the "hidden" field in your section editor then all will be well.