Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Hello
I have made a website witch couchcms which contains a list of dates with activities.
On the one hand there is a list of weekly activities that gets regularly update underneath there is a list of special activities these are often planned far ahead.

What I want to achieve is that when the special activity falls within the shown dates of the weekly activities it is added to the first list.

What I have now is:
Code: Select all
  <cms:pages masterpage='temp_agenda.php' orderby='ag_datum01' order='asc'>                                  
    <cms:if ag_check = '3'>
      <cms:if ag_activiteit1>
        <cms:set last_date="<cms:date ag_datum01 format='Ymd'/>" scope="global"/>
        -list...-
    <cms:else/>
      <cms:set cur_date="<cms:date ag_datum01 format='Ymd'/>" scope="global"/>
      <cms:if cur_date lt last_date>
        -list...-
      </cms:if>
    </cms:if>
  </cms:pages>


The variables work, I checked them. If I replace the last_date variable in the final cms:if with a number say '20150718' everything works. But with the variable nothing shows up.

Any obvious or less obvious thing I'm doing wrong?

Thank in advance
Korneel
Hi :)

What seems to be happening is that the 'cur_date' and the 'last_date' are being set in mutually exclusive code blocks (only one can execute - 'if' or 'else').

One solution could be to move the statement calculating the last_date to outside the if/else block so that it becomes available in both the blocks as follows -
Code: Select all
<cms:pages masterpage='temp_agenda.php' orderby='ag_datum01' order='asc'>    

    <cms:set last_date="<cms:date ag_datum01 format='Ymd'/>" scope="global"/>
   
    <cms:if ag_check = '3'>
      <cms:if ag_activiteit1>
       
        -list...-
    <cms:else/>
      <cms:set cur_date="<cms:date ag_datum01 format='Ymd'/>" scope="global"/>
      <cms:if cur_date lt last_date>
        -list...-
      </cms:if>
    </cms:if>
</cms:pages>

Hope it helps.
I thought the scope="global" solved that?
Anyhow it doesn't seem to solve the problem.
Anyhow it doesn't seem to solve the problem.
I don't have the complete code so won't be able to actually execute and test it. Can only provide pointers to you for debugging.

You had said -
If I replace the last_date variable in the final cms:if with a number say '20150718' everything works.
The statement in question is
Code: Select all
<cms:if cur_date lt last_date>

Try verifying what the value of last_date is just before the statement
Code: Select all
<h1><cms:show last_date /></h1>
<cms:if cur_date lt last_date>

Compare it to the value we put into last_date by printing it out at the place we set it -
Code: Select all
<cms:set last_date="<cms:date ag_datum01 format='Ymd'/>" scope="global"/>
<h1><cms:show last_date /></h1>

The two should match.

It is not a question of 'global' scope. The statement where we set 'last_date' was not getting executed at all in the original code when we compared it to cur_date.

Please let me know how it goes.
4 posts Page 1 of 1