How to detect a state change and display something?

With Plone 3.3.5, I have the classic contents of a folder, which is a list of events sorted by date (reverse). I show each item one by one. I would like to display a special message when the events are no longer in the future, but are past events.

Now I have this:

  <span tal:define="endDate item/end; 
           " tal:condition="python: endDate.isPast()">Past event<br />
  </span>

But I would like to display only one message, and not for all past events ...

I tried to create a Python variable but couldn't do it (mess with undeclared variable).

thanks for the help

PS: I am not familiar with the Plone template language ...

+3
source share
4 answers

, : . " " .

+3

, 0.

. "" .

+1

, , .

: http://docs.zope.org/zope2/zope2book/AppendixC.html#the-following-information-is-available-from-the-repeat-variable

tal: repeat , "" .

, isPast.

( ) ... .

<div tal:define="past string:Past events;
                 future string:Events to Come;
                 richList python:[{'event':'event1', 'passed': past},
                                  {'event':'event2', 'passed': future},
                                  {'event':'event3', 'passed': past},
                                  {'event':'event4', 'passed': future}];
                 dummy python:richList.sort(lambda x,y:cmp(x['passed'], y['passed']))">    


    <tal:block repeat="item richList">
        <h2 tal:condition="repeat/item/first/passed"
            tal:content="item/passed">
            Past Events or Future
        </h2>
      <a tal:content="item/event">event url</a>
        </tal:block>

    </div>

richList- . , "" event/end/isPast.

, .

+1

You can "filter" in listFolderContents in the same way as you can filter in a directory search. See http://collective-docs.plone.org/content/listing.html#getting-folder-objects-filtered how to do it. There is already an end index that you can include in your filter, see http://plone.org/documentation/manual/plone-community-developer-documentation/searching-and-indexing/query#querying-by-date

+1
source

All Articles