Hallo, I have two issues with new template in newscoop 3.5.3:
first I have a new article type with a date-field event_date. Can I sort with order in a {{ list_article }} instead of the standard order_condition? How?
Exampel
The new article type had a field event_date (date from a event). I want to sort the list_article by this date (asc or desc). {{ list-article order="????????" .......}} ------ {{ /list }}
second can I fix, that only the events in the future are showing. Is this a possibility:
{{ list ........ }}
{{ if $gimme->article->event_date|date_format greater $smarty.now|date_format}} {{ include file="kob_classic/tpl/event-show.tpl" }} {{ /if }}
{{ /list }}
???
Thanks
Best regards Hubertus (I'm a german and my english is not the best)
bycustom tells Newscoop you want to order by a custom field.
ci stands for Case Insensitive. Other possible values are cs (Case Sensitive) and num (Numeric)
event_date is the name of the custome field, in this case I used your field
1970-01-01 is a default value
That's it... this was implemented to be used with numeric and text fields, so I am not sure if it would work with dates but it might, so give a try and let us know if that makes the trick, it would be good to know :-)
This also reminds me that this is a new and undocumented feature :-) it will hit the manual soon ;-)
Second case:
Yes, everything is possible :-)
It should work the way you did it, but this is an optimized version:
I have tested. It, first case with {{ list_articles ... order="bycustom.ci.event_date.1970-01-01 desc" }} not be out of order. But, I do not know, wether my code-construction good is.
I have newscoop 3.5.3 with change template-set from classic. I have arrange a new article type (events with date and locations). The events sould list in a section (3). I have arranged code in section.tpl:
{{ if $gimme->section->number == "3" }} {{ list_articles name="events" order="bycustom.ci.event_date.1970-01-01 desc" constraints="type is events" ignore_issue="true" }}
{{ if $gimme->article->event_date|date_format:"%Y%m%d" >= $smarty.now|date_format:"%Y%m%d" }} {{ include file="kob_classic/tpl/event/event-show.tpl" }} {{ /if }}
{{ /list_articles }} {{ /if }}
The events are listed in section 3. The order="bycustom.ci.event_date.1970-01-01 desc" is ineffectual. Also, order="bycustom.ci.`$gimme->article->event_date`.1970-01-01 desc" is ineffectual.
The syntax is correct, problem is you are using 3.5.3, and ordering "bycustom" is available only as of 4.0.0. We suggest to plan for an upgrade, as many issues have been addressed since 3.5.3 plus several new features are available as well.
Upgrading might go not that straight forward, so do it first using a separate instance, don't do it at first on your production environment. If all goes well then you can approach the live instance.