removeDate and hidden field names

7 posts by 2 authors in: Forums > CMS Builder
Last Post: March 5, 2020   (RSS)

By shawn - March 3, 2020

Good day everyone

I was hoping someone would be able to assist. I am using a checkbox with the 'hidden' field name. I'm looking to also use the 'removeDate' field name so that you can either hide content by checking hidden or by date. I want it so that if its hidden using the checkbox, then the date field is irrelevant. However, if it's visible (unchecked), then it must only show if within the date period. 

I have the  checkbox working fine the following:

'tableName'   => 'bhs_promo',
'where'    => " hidden = '0' ", 
'orWhere'    => " hidden = '1' ",
'loadUploads' => true,
'allowSearch' => false,
'limit'       => '1',
<?php foreach ($bhs_promoRecords as $record): ?>
<?php if ($record['hidden'] == '0' ||  $record['hidden'] == ''): ?>
Content here...
<?php endif ?>
<?php endforeach ?>

I have no idea how to include the 'removeDate' field syntax? 

Thank you

By daniel - March 3, 2020

Hi shawn,

Is there a reason you'd prefer to do the filtering in the code? The hidden and removeDate fields can both be handled automatically by getRecords. If you have a date field named "removeDate" then getRecords should exclude any records A) with a date set, and B) where the date is in the past. As well, if you remove the "where" and "orWhere" parameters it should also handle removing any records marked hidden.

Thanks,

Daniel
Technical Lead
interactivetools.com

By shawn - March 3, 2020

Hi Daniel

I'm trying to do exactly the same as this but with the removeDate as well:
https://www.interactivetools.com/forum/forum-posts.php?postNum=2244283#post2244283

I'm only wanting certain content in the page to be hidden. If I use just the 'hidden' or 'removeDate', then I'm left with a white screen showing "Record not found!". 

If it's of any assistance, I'm using more than one section editor on this screen. 

By shawn - March 5, 2020

Hi Daniel,

Firstly thank you for this, I appreciate it. I have tested this and it works as long as the date is in the past, however if the time is in the past, it still remains visible.

So for example, I set the removeAfter date to yesterday and everything works perfectly. I change the removeAfter to today but a few minutes into the past and it does nothing. 

Any thoughts?

By shawn - March 5, 2020

Sorry I noticed it is working, but the time coming through is 2 hours behind my time. I think I just need to set the correct time zone?

By shawn - March 5, 2020

Nevermind Daniel, thank you again! I got it sorted - my timezone settings in the CMS Builder admin settings were incorrect. All good now!