Hi,
ListIt module hande matches (ice hockey). Manager have added all matches to module where all items have SelectDateTime information (gameday). Now I need to show only two games, which have same gameday and they are nearest to present time i.e two coming games i.e games, which are played next.
-R
Tips to automate ListIt items
Re: Tips to automate ListIt items
You may want to restate your question in a little more concise manner as to what you've done and what you need...
Re: Tips to automate ListIt items
This is possible if you are using CMSMS 1.11.x, means Smarty3 template engine.
First of all you would need to save SelectDateTime properly so you can sort items by these values for example in Fielddefinition Date Format option you would need something like yy-mm-dd which would produce 2013-10-21.
Then where you call your Games instance you need to sort it by this Fielddefinition for example {ListIt2Hockey orderby='custom_date|ASC' number='20'} (assuming your SelectDateTime Fielddefinition has alias "date" and maximum number of items that might not match would be 20, else remove or change number parameter as needed)
Then you need to check your custom dates and output matching results from within your Summary template.
You will need few Smarty3 features and php functions like:
strtotime (http://php.net/manual/en/function.strtotime.php)
append (http://www.smarty.net/docs/en/language. ... append.tpl)
break (http://www.smarty.net/docs/en/language. ... ruct.break)
while (http://www.smarty.net/docs/en/language. ... .while.tpl)
variable assign (http://www.smarty.net/docs/en/language. ... orm.assign)
A simple template would look like this:
First of all you would need to save SelectDateTime properly so you can sort items by these values for example in Fielddefinition Date Format option you would need something like yy-mm-dd which would produce 2013-10-21.
Then where you call your Games instance you need to sort it by this Fielddefinition for example {ListIt2Hockey orderby='custom_date|ASC' number='20'} (assuming your SelectDateTime Fielddefinition has alias "date" and maximum number of items that might not match would be 20, else remove or change number parameter as needed)
Then you need to check your custom dates and output matching results from within your Summary template.
You will need few Smarty3 features and php functions like:
strtotime (http://php.net/manual/en/function.strtotime.php)
append (http://www.smarty.net/docs/en/language. ... append.tpl)
break (http://www.smarty.net/docs/en/language. ... ruct.break)
while (http://www.smarty.net/docs/en/language. ... .while.tpl)
variable assign (http://www.smarty.net/docs/en/language. ... orm.assign)
A simple template would look like this:
Code: Select all
{foreach $items as $item}
{* compare fielddefinition date with current date, show greater or equal *}
{if $item->date|strtotime >= $smarty.now}
{* append $item to $output array *}
{append var='output' value=$item}
{if !isset($index) && empty($index)}
{$index = $item@index}
{/if}
{/if}
{* if we have $output and it counts 2 break the iteration *}
{if isset($output) && count($output) == 2}
{break}
{/if}
{/foreach}
{if !isset($output)}
{$output = $items}
{/if}
{* count $output until 2 *}
{while count($output) < 2}
{$index = $index-1}
{$output = $items.$index}
{/while}
{* reset $index *}
{$index = ''}
{* now build actual template *}
{foreach $output as $item}
{* this is where regular summary template would be *}
<h3>{$item->title}</h3>
<p>{$item->date|cms_date_format}</p> {* or use date_format modifier using strftime format *}
{/foreach}
Re: Tips to automate ListIt items
Thank You uniqu3, this was great. Never got email that someone has reply to this post.
-R
-R