<div class="mod_anynews"> <h2>{{ lang.TXT_HEADER }}</h2> {% if newsItems %} {% set germanmonth = ["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"] %} <ul> {% for news in newsItems %} <li>{{ germanmonth[news.PUBLISHED_WHEN | date("m") - 1] }} {% endfor %} </ul> {% else %} {{ lang.TXT_NO_NEWS }} {% endif %}</div>
'POSTED_WHEN' => $row['posted_when'], 'PUBLISHED_WHEN' => $row['published_when'], 'PUBLISHED_UNTIL' => $row['published_until'],'DATE_FORMAT' => $LANG['ANYNEWS'][0]['DATE_FORMAT'],
1. month index needs to be reduced by 1 as date("m") starts with 1 but Twig arrays starts with 0
2. template TIMESTAMP fields are already converted as datestring using settings in language file,
this needs to be removed from include.php to allow conversion of the numeric TIMESTAMP in Twig using the date modifier
Twig provides a lot of freedom compared to the previously used template. About all requested features since introduction of Twig could be realized by a customized Template, where before people had to hack the Anynews code itself.
Quote from: cwsoft on June 06, 2013, 07:08:59 AM2. template TIMESTAMP fields are already converted as datestring using settings in language fileI see but tried my "solution" on two different installations and both worked shocked, although it was not really clever to code like that.
2. template TIMESTAMP fields are already converted as datestring using settings in language file
Errors should never pass silently. Unless explicitly silenced.In the face of ambiguity, refuse the temptation to guess.
Quote from: cwsoft on June 06, 2013, 07:08:59 AMTwig provides a lot of freedom compared to the previously used template. About all requested features since introduction of Twig could be realized by a customized Template, where before people had to hack the Anynews code itself.so what now, but I guess you will still be a fan of template engines.
<ul>{% for news in newsItems %} <li>Dutch long: {{ news.TS_POSTED_WHEN | strftime('%A, %B %Y', ['nl_NL', 'dutch']) }}</li> <li>Dutch short: {{ news.TS_POSTED_WHEN | strftime('%a, %b %y', ['nl_NL', 'dutch']) }}</li> <li>German long: {{ news.TS_POSTED_WHEN | strftime('%A, %B %Y', ['de_DE', 'deu']) }}</li> <li>German short: {{ news.TS_POSTED_WHEN | strftime('%a, %b %y', ['de_DE', 'deu']) }}</li>{% endfor %}</ul>
{{ news.TS_POSTED_WHEN | strftime('%A, %B %Y', ['nl_NL', 'dutch']) | title }}
@argos: Did removing the quotes around the cwsoft-anynews droplet parameter solve your issues with the droplet call?
Thanks for your work!
Parse error: syntax error, unexpected T_FUNCTION in {removed}\wb\modules\cwsoft-anynews\include.php on line 107
Quote from: Argos on June 19, 2013, 12:01:15 AMThanks for your work! Great work but a couple of things that happened to me....>>> Just installed version 2.9 of anynews and get the following errorParse error: syntax error, unexpected T_FUNCTION in /home1/gvaaeu1/public_html/..domain../modules/cwsoft-anynews/include.php on line 107 which is described in the following lines of code.../** Add Twig filter to allow datetime conversion via PHP strftime function Example: {{ timestamp | strftime('%A, %B %Y', ['de_DE','german','deu']) }} Help on format strings: http://ch1.php.net/manual/en/function.strftime.php */$twig->addFilter(new Twig_SimpleFilter('strftime', function ($timestamp, $format, $locales) {setlocale(LC_ALL, $locales);return strftime($format, $timestamp);}));I had to comment out this line to get it to work.======================================Also i placed the anynews section just after the "minislider".... and two things have happened...... a) the news items have lost the ability to link (not click able0b) any time the cursor goes over the news item the mini slider pictures- puse... it treats the anynews section as its own ....picture space.... possibly a jquery problem. Any ideas?see http://sprintforce.com.au to verify my comment========================================System info: PHP 5.2.17, WB 2.83 sp1 (1638)Anynews code used:------------------------------ if (function_exists('displayNewsItems')) { echo displayNewsItems( $group_id = 0, $max_news_items = 4, $max_news_length = -1, $display_mode = 2, $lang_id = 'AUTO', $strip_tags = true, $allowed_tags = '<p><a><img>', $custom_placeholder = false, $sort_by = 1, $sort_order = 1, $not_older_than = 0, $group_id_type = 'group_id', $lang_filter = false );}
Tested on (wamp) PHP 5.2.6 with WB 2.8.3 SP1 (1638)
if (function_exists('getNewsItems')) { $options = array( 'max_news_items' => 4, 'display_mode' => 2, ); echo getNewsItems($options);}
@xoanon, Ruud: Uups, I implemented the Twig filter via an anonymous function (closure). Unfortunatelly closures where first introduced with PHP 5.3. I replaced the closure with a function call to support the outdated PHP 5.2.x series too.Would be great if somebody could download and test the latest version from the GitHub master branch. Please note: To convert a GitHub ZIP archive into a WebsiteBaker version, please follow the steps in the Download section.Cheers cwsoftP.S.: I will release cwsoft-anynews v2.9.1 once it was confirmed that the new version fixes the issue.
[[getNewsItems?display_mode=2]]
if (function_exists('getNewsItems')) { echo getNewsItems(array( 'group_id' => 0, 'max_news_items' => 4, 'max_news_length' => -1, 'display_mode' => 6, 'lang_id' => 'AUTO', 'strip_tags' => true, 'allowed_tags' => '<p><a><img>', 'custom_placeholder' => false, 'sort_by' => 1, 'sort_order' => 1, 'not_older_than' => 0, 'group_id_type' => 'group_id', 'lang_filter' => false, ));}
<style type="text/css">.twig_block {display:block;clear:both;width:100%;margin-bottom:10px;min-height:50px;overflow:auto;}.twig_date {width:20%;min-width:35px;float:left;}.twig_date .twig_day {background:#a8d591;color:#333;font-weight:bold;text-align:center;font-size:110%;border-radius:4px 4px 0 0;}.twig_date .twig_month {background:#5c9d3b;color:#fff;text-align:center;border-radius:0 0 4px 4px;font-size:70%;text-transform:uppercase;}.twig_title {float:right;width:75%;margin-top:-2px;}</style>{% for news in newsItems %} <div class="twig_block"> <div class="twig_date"> <div class="twig_day">{{news.PUBLISHED_WHEN|date('j')}}</div> <div class="twig_month">{{news.PUBLISHED_WHEN|date("M")}}</div> </div> <div class="twig_title"><a href="{{news.LINK}}">{{news.TITLE }}</a></div></div>{% endfor %}
[[getNewsItems?display_mode=2]]There was an unknown exception: An exception has been thrown during the rendering of a template ("DateTime::__construct() [datetime.--construct]: Failed to parse time string (10:02, 21/06/2013) at position 7 (2): Unexpected character") in "display_mode_6.htt" at line 38. in line (279) of (/modules/cwsoft-anynews/thirdparty/Twig/Twig/Template.php)