Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
Hello Forum!

In continuation with this post from before http://www.couchcms.com/forum/viewtopic.php?f=4&t=8211……

Displaying events that belong only to the current month works great :D . But since I have added a condition to display a sentence if there is no events in the current month, I have a problem :oops: ….The sentence won't appear...I was trying to understand where the problem lies, but I cannot find it….
I would appreciate a lot some help here..

Here is the code of what I have tried…

This is a list view of the template that has editable regions of the type "datetime" named "event_date" and "event_date_de".
I first made condition with regard to the language, so that I have displayed only english or only german version….All functions fine up to here….
When I add a condition within that, to define if the event_date within a current month is empty or not using
Code: Select all
<cms:not_empty event_date_de />

to display a text, that text won't display...
And I do not figure what I do wrong....


Code: Select all
<cms:if my_lang='en'> <!-- Language condition-->
   
   <h3>Current Month</h3>
<cms:pages  show_future_entries='1' custom_field="event_date >= <cms:show my_start_on /> | event_date < <cms:show my_stop_before />" orderby='event_date' order='asc' >
   <cms:if "<cms:not_empty event_date />">
      <div class="eventslist">
         <div class="eventtitle"><a href="<cms:show k_page_link />"><cms:show event_title /></a></div>
            
         <div class="eventdate"><cms:date event_date format='%b %d, %G' locale='english' charset='ISO-8859-1' /></div>
         <div><cms:show event_short/></div>
         </div>
     
   <cms:else/>
   There are no events in the current month. Please look the calender for the next events.
   </cms:if>
  </cms:pages>
      
    <cms:else/><!-- Language condition-->
   
   <h3>Aktueller Monat</h3>
   <cms:pages  show_future_entries='1' custom_field="event_date_de >= <cms:show my_start_on /> | event_date_de < <cms:show my_stop_before />" orderby='event_date_de' order='asc' >
   
      <cms:if "<cms:not_empty event_date_de />">
   
                  <div class="eventslist">
               <div class="eventtitle"><a href="<cms:show k_page_link />"><cms:show event_title /></a></div>
               <div class="eventdate"><cms:date event_date_de format='%d. %b. %G' locale='german' charset='ISO-8859-1' /> </div>
               <div><cms:show event_short/></div>
            </div>
        
      <cms:else/>
      Im aktuellen Monat habe wir keine Veranstaltungen.    Bitte sehen Sie unsere Termine f&uuml;r die n&auml;chste Veranstaltung.
      </cms:if>      
      </cms:pages>
      
  </cms:if><!-- Language condition-->


thanks in advance

Tanja
Tanja, the 'event_date' field that you are checking for empty within the cms:pages loop is very the field you asked cms:pages to use for fetching pages. Which translates to - within the cms:pages the 'event_date' will never be empty!

I think you should try using the cms:no_result for displaying conditions where no pages are fetched. Your code could become -
Code: Select all
<cms:pages  .. >

    <div class="eventslist">
        <div class="eventtitle"><a href="<cms:show k_page_link />"><cms:show event_title /></a></div>
        ...
        ...
    </div>


    <cms:no_results>
        There are no events in the current month. Please look the calender for the next events.
    </cms:no_results>
   
</cms:pages>

Notice how we have done away with the cms:if check.
Hope this helps.
Hello Kamran!

Thanks for clarifying what I was trying to do - I was not aware that event_date would never be empty...it is very logical though now when you say .....

The <cms:no_results> works perfectly... great and so simple to use tag....

kind regards


Tanja
3 posts Page 1 of 1
cron