Problems, need help? Have a tip or advice? Post it here.
11 posts Page 1 of 2
Hi Sir/Madam,

<cms:php>
global $CTX;
$CTX->set( 'datetime_now', date('Y-m-d', date("Y-m-d")), 'global' );
</cms:php>
<cms:editable name='blog_date' type='datetime' allow_time='0' am_pm='0'/>

<cms:if datetime_now > blog_date>
</cms:if>

If i want datetime_now greater than blog_date, the blog won't show on the blog page.

Kindly advise me.

Thanks.
Hi,

We'll assume your template has a 'datetime' region named 'expiry_date' -
Code: Select all
<cms:editable name='expiry_date' type='datetime' format='mdy'/>

The 'datetime_now' (i.e. current datetime) can be had using Couch tags as follows -
Code: Select all
<cms:date format='Y-m-d H:i:s' />

We can use that with 'custom_field' of cms:pages, as follows, to show only those pages that have not expired (i.e. expiry datetime is greater than the current datetime) -
Code: Select all
<cms:pages custom_field="expiry_date > <cms:date format='Y-m-d H:i:s' />">
    ...
</cms:pages>

Hope this helps.
Hi Sir/Madam,

<cms:pages custom_field="<cms:if> expiry_date > <cms:date format='Y-m-d H:i:s' /> <cms:else> condition2 </cms:if>">
</cms:pages>

Is it valid for custom_field? Because i cannot use "or".
kindly advise me.

Thanks.
'OR' is not supported, that is correct.

What exactly are you trying to code, anyway?
Can you please explain that in plain language (that is, not using Couch code).

Thanks.
Hi KK,

I had done start_date and end_date on my couchcms template and i want check datetime now with these 2 fields.

Condition 1:
if start_date no empty and end_date no empty then i need to use end_date to check datetime now greater than end_date and don't show the blog article.

Condition 2:
if start_date no empty and end_date is empty then i need to use start_date to check datetime now greater than start_date and don't show the blog article.
Perhaps this will give you something to build upon -
Code: Select all
<cms:if "<cms:not_empty end_date />">
    <cms:set my_expiry_date=end_date />
<cms:else />
    <cms:set my_expiry_date=start_date />
</cms:if>

<cms:pages custom_field="my_expiry_date > <cms:date format='Y-m-d H:i:s' />">
    ...
</cms:pages>

Does it help?
Hi KK,

If my date all expired custom_field, how to check the<cms:pages></cms:page> not result. Because i need to put no news message.

Kindly advise me.

Thanks.
Code: Select all
<cms:pages ..>
   ...
   ...
   
   <cms:no_results>
      <h3>No pages found</h3>
   </cms:no_results>

</cms:pages>
Hi KK,

Can i check with you if i want do a method at below:

<cms:page>
int i =0;

<cms:if ( true)>
<cms:else/>
i++;
</cms:if>

<cms:if i =='0'>
<cms:show "all true">
</cms:if>

</cms:page>
Can you please let me know (in plain English - no code please) what you are trying to achieve?
Thanks
11 posts Page 1 of 2
cron