Forum for discussing general topics related to Couch.
4 posts Page 1 of 1
I want to show a div until a selected date.
Therefore I have this div ...

Code: Select all
<div class="info"><cms:editable name='seminar' type='text' label='Next Seminar'>Next Seminar 12-12-2015</cms:editable></div>


I added a date chooser ...

Code: Select all
<cms:editable name='seminar_date' label='Date' desc='Enter date of the seminar' months='january, february, march, april, may, june, july, august, september, october, november, december' type='datetime' />  


Now I only want to output the div until 12-12-2015. After this date the div should not be outputted.

How can I make this working?
* * * * * * I LOVE COUCH CMS - flexible and straight forward * * * * * *
Hi,

The 'datetime' region always stores the date it contains in 'Y-m-d H:i:s' format -
try outputting its value (<cms:show seminar_date />) and you'll get something like:
2015-10-07 00:00:00

So now if we can get the current date in the same format, like this -
<cms:set my_current_date="<cms:date format='Y-m-d 00:00:00' />" />
// <cms:show my_current_date /> shows 2015-10-06 00:00:00

- it becomes a simple comparison of the two dates to conditionally show any content e.g. as follows
Code: Select all
<cms:set my_current_date="<cms:date format='Y-m-d 00:00:00' />" />

<cms:if my_current_date lt seminar_date>
    <div class="info">
        Next Seminar <cms:date seminar_date format='m-d-Y' />
    </div>
</cms:if>

Hope it helps.

P.S. If the div is meant only to show the date of the seminar, I think you don't need a separate editable region for that. Just display the date contained in the date field, as I did above.
Thank you so much :P
This works great and your answer was so complete.
smile chichi
* * * * * * I LOVE COUCH CMS - flexible and straight forward * * * * * *
I'm glad it helped, chichi :)
4 posts Page 1 of 1
cron