ListPage Fields

5 posts by 3 authors in: Forums > CMS Builder
Last Post: August 10, 2023   (RSS)

By mabsi - August 6, 2023 - edited: August 7, 2023

Hello

How to display number of days from creation date till today in the ListPage Fields 

Like below example:

Record No.      Creation Date     No. of Days
-------------------------------------------------------------------

     1                   2023-08-01              5

No. of Days=   NOW() - Creation date 

By mabsi - August 7, 2023 - edited: August 8, 2023

Thank you Robin for your reply

My question how to display the result of the query on CMSB  ListPage Fields and what should the field type

I tried using separator field as below code

<?php
$date1 = new DateTime(@$RECORD['createdDate']);
$date2 = new DateTime(date("Y-m-d H:i:s"));
$interval = $date1->diff($date2);
$days=$interval->days;
?>

<input type="text" style="width: 100%" name="lock_period" value="<?php echo $days;?>" readonly class="text-input form-control" data-dirrty-initial-value="">

its return the value in edit page as expected but didn't displayed on in the list page

Please find attached screen shot for more clarification 

Attachments:

Capture.JPG 51K

By Dave - August 9, 2023

Hi Mabsi, 

Unfortunately, there's no automatic way to do that.  

If you have some experience with PHP programming you could write a plugin to do it.  Some of CMS Builder internals are actually written as plugins.  So if you look at this file: cmsb/lib/menus/_outgoing_mail/actionHandler.php you can see how _ogm_cmsList_messageColumn() outputs custom content for a column.

You can also have a look at a sample plugin in the plugin folder here: cmsb/plugins/samplePlugin.php

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

By mabsi - August 10, 2023

Thank you Dave for your reply.

I will try and post here the solution