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 craig_bcd - May 8, 2019

Hi Deborah - 

Funny enough, that is the post I was referencing in my initial posting that I did not understand (pasted below) - Damon makes reference to "the hidden checkbox on the record" which I could not find at all (unless it is staring me in the face) and "adding the following to the view options" and I was just unclear if it is the view options on the page (like below) or somehow in the CMS section.  I wasn't sure if I was just supposed to create a "hidden" checkbox field and magically it would adopt those properties but since my "do_not_display" field was essentially the same thing with a different name. I included a screenshot of the current fieldlist in the leadership_sales section.

The alternative method he proposes is essentially the method you proposed and it has the same impact on the total count as your proposed method and i wanted to avoid writing record count code etc since the built in method does it so elegantly.

In any case, that is my current conundrum. 

thanks again for looking around.

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

One way you can exclude records from the multiSearch would be to use the "hidden" checkbox on the record. The record would then not appear in the search results.

To be able to link to the record directly and it have it display (even when marked as hidden) would  require that you add the following to the View Options:

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

Hope this helps. If you need any additional details about the steps or have questions, just let me know.

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