<?php
if (function_exists('register_frontend_modfiles')) {
register_frontend_modfiles('css');
register_frontend_modfiles('jquery');
register_frontend_modfiles('js');
} ?>
Flexslider looks good as long as it works with Anynews. I only see it working with images.As flexslider is already implemented in Anynews 2.1.0 ALPHA, it should work (display_mode = 4).
Already a fan of codaslider...Guess you are talking about coda-slider-2.0 (http://www.ndoherty.biz/tag/coda-slider/) - right?
Couldn't get the link to innerfade work.The link posted below works for me. Maybe do a Google search for "innerfade jQuery".
Old and good are also cycle-pluginThanks for the link, will have a look on this plugin.
Another is jcarouselliteAs this Plugin is not actively maintained (last update 2007) I doubt it will make it into cwsoft-anynews.
<?php
function displayNewsItems(
$group_id = 0, // IDs of news to show, matching defined $group_id_type (default:=0, all news, 0..N, or array(2,4,5,N) to limit news to IDs matching $group_id_type)
$max_news_items = 10, // maximal number of news shown (default:= 10, min:=1, max:= 999)
$max_news_length = -1, // maximal length of the short news text shown (default:=-1 => full news length)
$display_mode = 1, // 1:=details (default); 2:=list; 3:=coda-slider; 4:flexslider; 4-98 (custom template: display_mode_X.htt); 99:=cheat sheet
$lang_id = 'AUTO', // language file to load and lang_id used if $lang_filer = true (default:= auto, examples: AUTO, DE, EN)
$strip_tags = true, // true:=remove tags from short and long text (default:=true); false:=don´t strip tags
$allowed_tags = '<p><a><img>', // tags not striped off (default:='<p><a><img>')
$custom_placeholder = false, // false:= none (default), array('MY_VAR_1' => '%TAG%#', ... 'MY_VAR_N' => '#regex_N#' ...)
$sort_by = 1, // 1:=position (default), 2:=posted_when, 3:=published_when (only WB 2.7), 4:= random order, 5:=number of comments
$sort_order = 1, // 1:=descending (default), 2:=ascending
$not_older_than = 0, // 0:=disabled (default), 0-999 (only show news `published_when` date <=x days; 12 hours:=0.5)
$group_id_type = 'group_id', // type used by group_id to extract news entries (supported: 'group_id', 'page_id', 'section_id', 'post_id')
$lang_filter = false // flag to enable language filter (default:= false, show only news from a news page, which language fits $lang_id)
);
<?php
/**
* Code snippet: anynews
*
* This code snippets grabs news from the WB news module database
* and displays them on any page you want by invoking the function
* displayNewsItems() via a page of type code or the index.php
* file of the template.
*
* This file contains the Dutch language output.
*
* LICENSE: GNU General Public License 3.0
*
* @platform CMS WebsiteBaker 2.8.x
* @package anynews
* @author cwsoft (http://cwsoft.de)
* @translation forum member Dave (ak D72), Argos
* @version 2.2.0
* @copyright cwsoft
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// Dutch module description
$module_description = 'Snippet om nieuwsberichten te tonen op elke pagina die u maar wilt. Functie kan opgeroepen worden vanuit de template of een code-sectie. Meer informatie is te vinden op <a href="https://github.com/cwsoft/wb-anynews" target="_blank">GitHub</a>.';
// initialize global $LANG variable as array if needed
if (! isset($LANG) || (isset($LANG) && ! is_array($LANG))) {
$LANG = array();
}
$LANG['ANYNEWS'][0] = array(
// text outputs for the frontend
'TXT_HEADER' => 'Laatste nieuws',
'TXT_READMORE' => 'Lees meer',
'TXT_NO_NEWS' => 'Geen nieuws beschikbaar.',
'TXT_NEWS' => 'Nieuws',
'TXT_NUMBER_OF_COMMENTS' => 'Aantal reakties',
// date/time format: (9:12 PM, 31-12-2012)
'DATE_FORMAT' => ' (d-m-Y, H:M)'
);
Great notes and love the idea of separating the custom js from the 3rd party js. However...The custom aspects of the coda slider are located in 3rd party folder.Thanks. Unfortunatelly, the old "better-coda-slider" is not build as jQuey plugin and not maintained by the developer anymore. If someone wants to create a plugin from the files included, please do so. Will than update my files accordingly. I keept the "better-coda-slider" mainly for backwards compatibility, but would recommend to switch to flexslider instead. As alternative you may want to implement another jQuery plugin, which should be fairly simple with the updated cwsoft-anynews version :wink:
<?php
ob_start();
show_menu2(0, SM2_CURR+1, SM2_CURR+1);
$childmenu = ob_get_contents();
ob_end_clean();
?>
I put the PHP info in the test area as well. I was able to get the php version, but wow it is running slow.My browser required 15 seconds to display the PHP info (which you never should t make public by the way) from your website. On my website it takes about 560 micro seconds to display the PHP info, which is a factor of 26. So yes, there is something wrong on your site.
Is there any way that this pagination feature could be integrated into AnyNews?Of course, everything can be integrated :wink:
... one question is it possible to truncate the title?Without touching the code, this can be realized with a custom Anynews template implementing one of the available jQuery truncate plugins (http://google.com/search?q=jquery+truncate). Reciept for implementation similar to this post (https://forum.WebsiteBaker.org/index.php/topic,23355.msg161525.html#msg161525).
'TITLE' => substr(($strip_tags) ? strip_tags($row['title']) : $row['title'], 0, X),
{{ news.TITLE | slice(0,X) }}
Thanks for the update of anynews, one question is it possible to truncate the title?I made this droplet (https://forum.WebsiteBaker.org/index.php/topic,23170.msg156383.html#msg156383) for truncating the shorttext of news module without using jQuery. Maybe you can adapt it for your needs.
'TITLE' => substr(($strip_tags) ? strip_tags($row['title']) : $row['title'], 0, X),
<?php // ignore opening tag
$loader = new Twig_Loader_Filesystem(array(WB_PATH.'/templates/' .TEMPLATE. '/anynews', dirname(__FILE__) . '/templates'));
<?php // ignore opening tag
/**
* Load Anynews Twig template specified via $display_mode
*/
if (file_exists(WB_PATH.'/templates/' .TEMPLATE. '/anynews/display_mode_' . $display_mode . '.htt')) {
$tpl = $twig->loadTemplate('display_mode_' . $display_mode . '.htt');
}elseif (file_exists(dirname(__FILE__) . '/templates/display_mode_' . $display_mode . '.htt')) {
$tpl = $twig->loadTemplate('display_mode_' . $display_mode . '.htt');
} else {
$tpl = $twig->loadTemplate('display_mode_1.htt');
}
suggestion:Code: [Select]<?php // ignore opening tag
$loader = new Twig_Loader_Filesystem(array(WB_PATH.'/templates/' .TEMPLATE. '/anynews', dirname(__FILE__) . '/templates'));
// and 83 ff.
/**
* Load Anynews Twig template specified via $display_mode
*/
if (file_exists(WB_PATH.'/templates/' .TEMPLATE. '/anynews/display_mode_' . $display_mode . '.htt')) {
$tpl = $twig->loadTemplate('display_mode_' . $display_mode . '.htt');
}elseif (file_exists(dirname(__FILE__) . '/templates/display_mode_' . $display_mode . '.htt')) {
$tpl = $twig->loadTemplate('display_mode_' . $display_mode . '.htt');
} else {
$tpl = $twig->loadTemplate('display_mode_1.htt');
}
<?php
$loader = new Twig_Loader_Filesystem(array(WB_PATH.'/templates/'.TEMPLATE.'/anynews', dirname(__FILE__).'/templates'));
// throws an exception if a given directory not exists
// and 83 ff.
try{
$tpl = $twig->loadTemplate('display_mode_'.$display_mode.'.htt');
}catch(Twig_Error_Loader $e){
// if first loadTemplate() fails, catch exception and try to load default template
$tpl = $twig->loadTemplate('display_mode_1.htt');
}
<?php // ignore opening php tag
/**
* Create Twig template object and configure it
*/
require_once (WB_PATH.'/include/Twig/Twig/Autoloader.php');
Twig_Autoloader::register();
$aLoaderDir = array(dirname(__FILE__) . '/templates');
if(file_exists(WB_PATH.'/templates/' .TEMPLATE. '/anynews')){
// put TEMPLATE.'/anynews' Directory at the beginning of array if it exists
array_unshift($aLoaderDir, WB_PATH.'/templates/' .TEMPLATE. '/anynews');
}
$loader = new Twig_Loader_Filesystem($aLoaderDir);
<?php // ignore opening php tag
/** Create Twig template object and configure it */
/* from WB2.8.x Rev.1687 the Twig_autoloader ist activated by default
so it [u][b]never[/b][/u] should be loaded or registered explicite!
// require_once (WB_PATH.'/include/Twig/Twig/Autoloader.php');
// Twig_Autoloader::register();
*/
try{
$loader = new Twig_Loader_Filesystem(WB_PATH.'/templates/'.TEMPLATE.'/anynews');
$loader->addPath(dirname(__FILE__).'/templates');
}catch(Twig_Error_Loader $e) {
$loader = new Twig_Loader_Filesystem(dirname(__FILE__).'/templates');
}
Have a look inside the class documentation (or the classes itself). You will find an endless bunch of possibilitiesI will.
It seems the AnyNews module/snippet is becoming more advanced and complex than the News module itself...
It seems the AnyNews module/snippet is becoming more advanced and complex than the News module itself.Regarding complexity. Anynews was developed with the main audience of "medium to advanced users" in mind. Regarding flexibility. Anynews was designed to aggregate news from the WB news module in various ways in order to display them in the frontend with more design and layout possibilities than offered by the WB news module.
It's great to see AnyNews being developed.For the WB 2.8.x series, I do not plan to add much new features to cwsoft-anynews (v2.3.0), unless there is a huge demand and push from the user base and a sound reason for doing so. So cwsoft-anynews is not really developed but maintained :wink:
I really meant that the News module input/backend options and flexibility are getting less attention than output/frontend optionsSome forum posts indicate that for WB 2.9, there will be a entirely rewrite of the News module, with much for features, better user experience and much more :wink: Lets see if cwsoft-anynews will still have a niche in WB 2.9 eco system.
I basically just copied over your initial Dutch language files you posted here (https://forum.WebsiteBaker.org/index.php/topic,23355.msg159758.html#msg159758) without further checking.
Not too sure about your proposal to move the () to the template instead of the data format. Will see if I change it or keep it as it was up to know since the very first releases of Anynews.
Sorry about this mistake! I just accidentally noticed it when I used your updated AnyNews in a new site.Guess you refer to cwsoft-anynews 2.4.0 not to the latest Github version where I already replaced H:M with H:i - right?
It cost me about 30 minutes to find out that they were part of the language file..Well then this must be the first time you needed this, as the brackets in the language file DATE_FORMAT string was already introduced with the initial Anynews version I published a couple of years ago :-) Anyway, will think about it and decide later on.
displayNewsItems((11,13), 1, -1, '','', '', '', '','', '','');This code won´t work.
$group_id = array(11,13)Note the word "array".
$group_id = array(14,16)and the error message I would assume there is just a comma missing:
$group_id = array(14,16),
Why the stupid name change?Just curious. Is there any special reason for your offensive question?
You should better honor the products people provide to the community for free
And I don't like it how you treat developers hereI am not here to be nice, i am trying to be helpful
Q1: What exactly are the issues/concerns caused by the name change compared to any previous update for you or your clients?
Q2: Compared to previous updates (without name changes), in which process of the installation/upgrade path get you or your clients confronted with the name change?
Q3: What are the consequences or side effects for you and your clients caused by the name change (compared to any previous update), e.g. page / template or documentation updates ...
If you want to help, please try to answer the questions instead of re-questioning them.
PLEASE NOTE: Please delete any possible existing previous Anynews module via the WebsiteBaker backend BEFORE installing the new version, as the database names have changed.
- for less advanced/experienced wb-users: unclearity if this is a totally new version, just an update or a new module possibly resulting in a chaotic maze of moduleversions and variations
Dear stefek,
... redirecting me to google kinda pisses me off as it suggests you think i am choosing the easy way and whitout thinking just putting in nonsense questions, this kind of behaviour here does not do much good to the reputation of the whole community.
A name change takes place most of the times in case of forking. AnyNews is a well known and long lasting module, so a name change should have a real purpose. If this version differs very much from the previous ones, you could see it as a fork, leaving regular AnyNews as it is.Since February 2012, I added around 46'000 and removed 31'000 code lines from Anynews (https://github.com/cwsoft/wb-cwsoft-anynews/graphs/impact) (including Twig, header changes etc.).
PLEASE NOTE: Please delete any possible existing previous Anynews module via the WebsiteBaker backend BEFORE installing the new version, as the database names have changed.Uups, this statement was copied over from the announcement posts of the "cwsoft-postits" and "cwsoft-addon-file-editor modules". Anynews is a code snippet and does not add or change any database settings. However one should delete a previous installed Anynews module in order not to have two versions of it :wink:
for less advanced/experienced wb-users: unclearity if this is a totally new version, just an update or a new module possibly resulting in a chaotic maze of moduleversions and variationsI think the release of modules and patches via the forum is much more chaotic than the way I started at GitHub, as all my code changes can easily be traced online (https://github.com/cwsoft/wb-cwsoft-anynews/commits/master) (and reverted if needed). However, I do hope that some of the actual issues will sort out once the brand new WebsiteBaker repository (http://addons.websitebaker2.org/pages/en/home.php) will be officially released and the "old module repository" is shut down. Think the new repository will only list newer modules (from 2.8.x onwards).
<?php
displayNewsItems(1,5,-1,5,'AUTO',true,'<a><br />')
?>
{% for news in newsItems %}
<a href="{{ news.LINK }}"><strong>{{ news.TITLE }}</strong></a><br />
{{ news.CONTENT_SHORT}}<br /><br />
{% endfor %}
<p>Sa. 15.12.2012, 16.00 Uhr<br />
Amtshauskeller Frdbg.<br />
Eintritt frei</p>
Sa. 15.12.2012, 16.00 Uhr<br />
Amtshauskeller Frdbg.<br />
Eintritt frei
Sa. 15.12.2012, 16.00 Uhr
Amtshauskeller Frdbg.
Eintritt frei
So it seems that the "<br />" Tag is striped althought it is allowed.just allow the "normal form" of the tag:
displayNewsItems(1,5,-1,5,'AUTO',true,'<a><br>')
Woow,
that was easy. Sometimes one thinks to complicated.
Thanks marmot, it works like a charm.
Matthias
This parameter should not contain whitespace. strip_tags() sees a tag as a case-insensitive string between < and the first whitespace or >. It means that strip_tags("<br/>", "<br>") returns an empty string.
if (function_exists('displayNewsItems')) {
displayNewsItems(
$group_id = 0,
$max_news_items = 2,
$max_news_length = 40,
$display_mode = 1,
$lang_id = 'AUTO',
$lang_filter = true,
$strip_tags = true,
$allowed_tags = '<p><a>',
$custom_placeholder = false,
$sort_by = 1,
$sort_order = 1,
$not_older_than = 0,
$group_id_type = 'group_id'
);
<div class="mod_anynews">
<h2>{{ lang.TXT_HEADER }}</h2>
{% for news in newsItems %}
<p>
<strong>{{ news.TITLE }} ({{ news.POSTED_WHEN }})</strong>
</p>
{{ news.CONTENT_SHORT}}
{% if news.CONTENT_LONG %}
<a href="{{ news.LINK }}">{{ lang.TXT_READMORE }}</a>
{% endif %}
<hr />
{% else %}
{{ lang.TXT_NO_NEWS }}
{% endfor %}
</div>
<?php
/**
* Code snippet: cwsoft-anynews
*
* This code snippets grabs news entries from the WebsiteBaker news
* module and displays them on any page you want by invoking the function
* displayNewsItems() via a page of type code or the index.php
* file of the template.
*
* This file contains the English language output.
*
* LICENSE: GNU General Public License 3.0
*
* @platform CMS WebsiteBaker 2.8.x
* @package cwsoft-anynews
* @author cwsoft (http://cwsoft.de)
* @copyright cwsoft
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// Czech module description
$module_description = 'Tento modul cwsoft-anynews umožňuje zobrazovat vaše aktuality ze systému WebsiteBaker na jakémkoliv místě. Funkci můžete použít v sekci Code na jakékoliv stránce nebo ve vaší šabloně v souboru index.php. Detaily viz <a href="https://github.com/cwsoft/wb-cwsoft-anynews#readme" target="_blank">GitHub</a>.';
// initialize global $LANG variable as array if needed
global $LANG;
if (! isset($LANG) || (isset($LANG) && ! is_array($LANG))) {
$LANG = array();
}
$LANG['ANYNEWS'][0] = array(
// text outputs for the frontend
'TXT_HEADER' => 'Aktuality',
'TXT_READMORE' => 'číst více',
'TXT_NO_NEWS' => 'Nejsou k dispozici žádné aktuality.',
'TXT_NEWS' => 'Novinky',
'TXT_NUMBER_OF_COMMENTS' => 'Počet komentářů',
// date/time format: (9:12 PM, 12/31/2012)
'DATE_FORMAT' => 'H:i, j.n.Y'
);
<?php
if (function_exists('displayNewsItems')) {
displayNewsItems(
$group_id = 0,
$max_news_items = 3,
$max_news_length = 40,
$display_mode = 2,
$lang_id = 'AUTO'
) ;
}
?>
Here is a Czech translationGreat, thank you very much, uploaded the Czech file to the GitHub repository (https://github.com/cwsoft/wb-cwsoft-anynews/commit/9ac81a70cc477fc30fe0d25da1046565aaa3fe24). As I released Anynews 2.7.0 (http://addons.websitebaker2.org/pages/en/browse-add-ons.php?id=0C80D11) just yesterday, I will wait at least until WB 2.8.4 gets released before I publish a new Anynews version :wink:
Also, for some reason the $max_news_length is not working for me.The parameter $display_mode = 2; will only show the news TITLE in a list view and not the news text. Hence the parameter $max_news_length = XX; is not effective for this display mode. Set display mode to 1 and try again.
The parameter $display_mode = 2; will only show the news TITLE in a list view and not the news text. Hence the parameter $max_news_length = XX; is not effective for this display mode. Set display mode to 1 and try again.
If you run into the same issue with display_mode = 1, please try to add the parameter $strip_tags = false to your Anynews function call. See Anynews parameter description (https://github.com/cwsoft/wb-cwsoft-anynews#anynews-parametes) at GitHub for details.
If the above proposals don't work for you, please report back in the forum so we can fix your issue.
Cheers cwsoft
<div class="mod_anynews">
{% if newsItems %}
<ul>
{% for news in newsItems %}
<li><a href="{{ news.LINK }}"><strong>{{ news.POSTED_WHEN }} | {{ news.TITLE }}</strong><br />{{ news.CONTENT_SHORT}}</a></li>
{% endfor %}
</ul>
{% else %}
{{ lang.TXT_NO_NEWS }}
{% endif %}
</div>
<div class="mod_anynews">
{% if newsItems %}
<ul>
{% for news in newsItems %}
<li>
<a href="{{ news.LINK }}">
<strong>{{ news.POSTED_WHEN }} | {{ news.TITLE }}</strong><br />
{{ news.CONTENT_SHORT | slice(0,20) }}
{% if news.CONTENT_SHORT | length > 20 %}
...
{% endif %}
</a>
</li>
{% endfor %}
</ul>
{% else %}
{{ lang.TXT_NO_NEWS }}
{% endif %}
</div>
Great module, but I want the anynews droplet for display latest news on specific wysiwyg pages, not only on "code" pages. Any ideas? I think it must be very simple droplet, but I not php programmer. :-(
@dana
First, I recommend NOT to modify the template files shipped with Anynews. Better create a copy of the original template ("display_mode_2.htt" --> "display_mode_5.htt") and modify the copy (remember to adapt $display_mode to the number of your template).
The actual truncate implementation (http://alanwhipple.com/2011/05/25/php-truncate-string-preserving-html-tags-words/) was done by the WebsiteBaker community, but never fully tested for all possible use cases (e.g. multibyte encoding, malformed HTML/XML ...). Basic idea was not to cut HTML tags and single words. My initial implementation was to strip off tags and truncate plain text, which is much easier but less comfortable :wink:
Could you please check the following in your code:
a) enter PLAIN text into WB News short news filed: "this is some text, just to test"
b) set $max_news_length = 10 --> results in: "this..."
c) set $max_news_length = 11 --> results in: "this is..."
*snip*
I think I have figured out where the problem is.Great. Would be good if you could test the latest version available at GitHub and report any possible issues, as I intend to release the updated truncate version with the next Anynews version.
Here is Russian translation.Thank you very much. Could you please also translate the module description stored in variable $module_description of the RU.php file? I will upload your language file to GitHub, once translation is complete.
No, my idea is to make a droplet, which calls displayNewsItems(), and possibility for the user to include [[cwsoft-anynews]] to wysiwyg for placing news on the some page.Good idea, never thought about it.
// include cwsoft-anynews code
require_once(WB_PATH . '/modules/cwsoft-anynews/include.php');
// execute Anynews
ob_start();
displayNewsItems(
$group_id = 0,
$max_news_items = 10,
$max_news_length = -1,
$display_mode = 4,
$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
);
$output = ob_get_contents();
ob_end_clean();
// return Anynews output
return $output;
if (! file_exists(WB_PATH . '/modules/cwsoft-anynews/droplet/cwsoft-anynews-droplet.php')) return;
include(WB_PATH . '/modules/cwsoft-anynews/droplet/cwsoft-anynews-droplet.php');
return $output;
it seems that the section_id, group_id does not work.Your code won't work. The parameter 'section_id' is no valid Anynews parameter. Your code example sets 'group_id' = 0 (DEFAULT), which outputs news from ALL groups available.
$config = array(
'group_id' => 8,
'group_id_type' => 'section_id',
);
Thanks for the help, it works now.I thank you for your example allowing to show the more flexible configuration in a real world example.
if (function_exists('getNewsItems')) {
echo getNewsItems();
}
If so how?$max_news_length = 30,
$display_mode = 3,
Can one code section also pass parameters?Note quite sure I really understand what you are after, but lets try.
if (function_exists('getNewsItems')) {
echo getNewsItems(array(
'max_news_length' => 30,
'display_mode' => 3,
));
}
if (function_exists('getNewsItems')) {
$options = array(
'max_news_length' => 30,
'display_mode' => 3,
);
echo getNewsItems($options);
}
I chose option 2. It now works as it should.Glad it worked. I prefer this option too, as it is more obvious for the reader.
[[getNewsItems?group_id=27&max_news_items=5&max_news_length=80&display_mode=50¬_older_than=360&group_id_type='section_id']]
[[getNewsItems?group_id=9&max_news_items=5&max_news_length=80&display_mode=50¬_older_than=360&group_id_type='page_id']]
It seems the section_id and page_id parameters don't work. I have this droplet, which should show the news from news section ID 27, but instead it shows the "no news available" line.Anynews droplet parameters needs to be passed over without quotes (see section_id):Code: [Select][[getNewsItems?group_id=27&group_id_type='section_id']]
[[getNewsItems?group_id=27&group_id_type=section_id]]
And also the regular code calls don't seem to work with page_id and section_id...Can't confirm this. Code inside a code section works for me with cwsoft-anynews 2.8.2 and the example code (https://github.com/cwsoft/wb-cwsoft-anynews#anynews-configuration) at GitHub.
@argos: Date formats can be defined via Twig date function (http://twig.sensiolabs.org/doc/filters/date.html) and a modified Anynews template. If default date filters provided by Twig are not sufficient for you, one can code it's own Twig function or extension to transform whatever is needed.
{% 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 %}
.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;}
I almost got it, except that the month is in English, and doesn't follow the locale set in the admin. How can I change that?For this task, the datetime filter (https://github.com/fabpot/Twig/issues/378) is used. However, it would need to be activated.
Doesn't this Twig stuff just add a big layer of complexity to this snippet?Not really. Date formating is more a shortcoming of PHP, which was improved in PHP 5.x series.
I almost got it, except that the month is in English, and doesn't follow the locale set in the admin. How can I change that?maybe this way:
find fixed code below
Thanks marmot. It doesn't work however.now it does (just a missing "[" in line 1:
{% set germanmonth = ["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"] %}
{% 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">{{germanmonth[news.PUBLISHED_WHEN|date("m")]}}</div>
</div>
<div class="twig_title"><a href="{{news.LINK}}">{{news.TITLE }}</a></div>
</div>
{% endfor %}
<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 0ok I missed that completely.
2. template TIMESTAMP fields are already converted as datestring using settings in language file,I see but tried my "solution" on two different installations and both worked :-o, although it was not really clever to code like that.
this needs to be removed from include.php to allow conversion of the numeric TIMESTAMP in Twig using the date modifiervs
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.so what now, but I guess you will still be a fan of template engines. :wink:
This depends if the PHP DateTime (http://php.net/manual/en/book.datetime.php) conversion succeeds or fails. Set WB language to English and you will most likely see an error like this: "An exception has been thrown during the rendering of a template ("DateTime::__construct(): Failed to parse time string (5:02 PM, 02/09/2013) at position 5 (P)". This is due to invalid timezone / datetime string settings. Removing the comma from the Anynews EN.php will most likely do the trick for English. However, to be on the safe site, one should use the numeric TIMESTAMP.2. 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.
Errors should never pass silently. Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
Sure, Twig still rocks.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.so what now, but I guess you will still be a fan of template engines. :wink:
<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
Thanks 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 error
Parse 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 able0
b) 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 (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 (https://github.com/cwsoft/wb-cwsoft-anynews/archive/master.zip) 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 (https://github.com/cwsoft/wb-cwsoft-anynews#download) in the Download section.
Cheers cwsoft
P.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)
>>>>>.Hello Cwsoft, thank you for your help, I was finally able to get it to work with the getNewsItems thing instead of the previous one!Good to here you solved it.
Do you have a download link for getNewsItems?Download link is posted several times here in the forum. See post #148 (7 posts before) for example :wink:
<?php
if (function_exists('getNewsItems')) {
echo getNewsItems();
$config = array(
'group_id' => 0,
'max_news_items' => 10,
'max_news_length' => -1,
'display_mode' => 1,
'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,
);
}
?>
Is this call right?Not really. As you call getNewsItems() without passing over the config array, the default settings are used and the stuff you have defined in the Array $config is simply ignored.
// customized cwsoft-anynews function call
$config = array(
'group_id' => 8,
'group_id_type' => 'section_id',
'display_mode' => 4,
);
echo getNewsItems($config);
$config = array(
'display_mode' => 3,
);
echo getNewsItems($config);
<?php
/**
* Code snippet: cwsoft-anynews
*
* This code snippets grabs news entries from the WebsiteBaker news
* module and displays them on any page you want by invoking the function
* displayNewsItems() via a page of type code or the index.php
* file of the template.
*
* This file contains the English language output.
*
* LICENSE: GNU General Public License 3.0
*
* @platform CMS WebsiteBaker 2.8.x
* @package cwsoft-anynews
* @author cwsoft (http://cwsoft.de)
* @copyright cwsoft
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// English module description
$module_description = 'This kodestump cwsoft-anynews gør det muligt at vise nyheder poster fra WebsiteBaker news modul på ethvert sted, du ønsker. Kalder funktionen fra en kode sektion eller din skabelon index.php fil. For nærmere oplysninger se <a href="https://github.com/cwsoft/wb-cwsoft-anynews#readme" target="_blank">GitHub</a>.';
// initialize global $LANG variable as array if needed
global $LANG;
if (! isset($LANG) || (isset($LANG) && ! is_array($LANG))) {
$LANG = array();
}
$LANG['ANYNEWS'][0] = array(
// text outputs for the frontend
'TXT_HEADER' => 'Seneste nyheder',
'TXT_READMORE' => 'Læs mere',
'TXT_NO_NEWS' => 'Ingen nyheder.',
'TXT_NEWS' => 'Nyheder',
'TXT_NUMBER_OF_COMMENTS' => 'Antal kommentar',
// date/time format: (21:12 12/31/2012)
'DATE_FORMAT' => 'G:i, d/m/Y'
);
Here's the Danish language fileGreat - thanks for your contribution. Uploaded your file to GitHub (https://github.com/cwsoft/wb-cwsoft-anynews/commit/bb3ee79d038a22fc9298a4ad239479bb3dc5b4f5), so it will be distributed with the next cwsoft-anynews release and mentioned you in the Credit section (https://github.com/cwsoft/wb-cwsoft-anynews#credits) of the README file.
require_once(WB_PATH . '/modules/cwsoft-anynews/code/anynews_functions.php');
getGroupIdTypes($sort_column = "post_id", $sort_order = "ASC", $output = true);
'DATE_FORMAT' => 'H:i, d.m.Y'
'DATE_FORMAT' => 'j M'
Is it possible to place news items next to each other? I have included an image.Yes this can be achieved with a customized Anynews template and some CSS rules. Some basics about Anynews templates can be found in the README (https://github.com/cwsoft/WebsiteBaker-anynews#anynews-templates) at GitHub.
<?php
/**
* Code snippet: cwsoft-anynews
*
* This code snippets grabs news entries from the WebsiteBaker news
* module and displays them on any page you want by invoking the function
* getNewsItems() via a page of type code or the index.php
* file of the template.
*
* This file contains the Slovenian language output.
*
* LICENSE: GNU General Public License 3.0
*
* @platform CMS WebsiteBaker 2.8.x
* @package cwsoft-anynews
* @author cwsoft (http://cwsoft.de)
* @copyright cwsoft
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// Slovenian module description
$module_description = 'Dodatek cwsoft-anynews omogoča prikaz novic iz WebsiteBaker News modula, na katerem koli mestu na strani. Funkcijo prikličete iz oddelka kode ali vaše predloge index.php datoteke. Za podrobnosti glej <a href="https://github.com/cwsoft/wb-cwsoft-anynews#readme" target="_blank">GitHub</a>.';
// initialize global $LANG variable as array if needed
global $LANG;
if (! isset($LANG) || (isset($LANG) && ! is_array($LANG))) {
$LANG = array();
}
$LANG['ANYNEWS'][0] = array(
// text outputs for the frontend
'TXT_HEADER' => 'Zadnje Novice',
'TXT_READMORE' => 'beri več',
'TXT_NO_NEWS' => 'Trenutno ni novic.',
'TXT_NEWS' => 'Novice',
'TXT_NUMBER_OF_COMMENTS' => 'Število komentarjev',
// date/time format: (21:12, 31/10/2012)
'DATE_FORMAT' => 'G:i, d/m/Y'
);
Slovenian translation (SL.php) ---> It should be SI.php not SL (SL is for Slovakia)I thought WebsiteBaker follows the two letter language code defined in ISO 639-1 (http://www.sitepoint.com/web-foundations/iso-2-letter-language-codes), also see WIKI (http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
ISO 639-1 is correct for all WB-Versions up to 2.8.4 and laterQuoteSlovenian translation (SL.php) ---> It should be SI.php not SL (SL is for Slovakia)I thought WebsiteBaker follows the two letter language code defined in ISO 639-1 (http://www.sitepoint.com/web-foundations/iso-2-letter-language-codes), also see WIKI (http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
In ISO 639-1, SL stands for Slovenian, SK for Slovak and SI for Sinhala. Maybe an developer can confirm this :wink:
This is why I used SL (Slovenian) for your language file.
2*3ALPHA (ISO 639-1 | 639-2/T) | language |
2ALPHA (ISO3166) | region |
3*5alphanum (registered Variants) | variant |
<?php
if (function_exists('getNewsItems')) {
echo getNewsItems(
$group_id = 1,
$display_mode = 1);
}
?>
<?php
if (function_exists('getNewsItems')) {
$config = array(
'group_id' => 1,
'display_mode' => 1,
);
echo getNewsItems($config);
}
?>
if (function_exists('getNewsItems')) {
echo getNewsItems(
$group_id = 3,
$display_mode = 1);
}
<div id="leftsideColumn">
<div class="leftsidebox">
<!-- CODE BELOW uses the AnyNews 2.14.0 installed module -->
<div id="display_anynews">
<?php
if (function_exists('getNewsItems')) {
$config = array(
'group_id' => 1,
'display_mode' => 1,
);
echo getNewsItems($config);
}
?>
</div><!-- end display_anynews -->
</div><!-- end leftsidebox -->
</div><!-- end leftsideColumn -->
<div id="rightsideColumn">
<div class="rightsidebox">
<!-- CODE BELOW uses the AnyNews 2.14.0 -->
<div id="display_anynews">
<?php
if (function_exists('getNewsItems')) {
$config = array(
'group_id' => 2,
'display_mode' => 1,
);
echo getNewsItems($config);
}
?>
</div><!-- end display_anynews -->
</div><!-- end rightsidebox -->
</div><!-- end leftsideColumn -->
[[getNewsItems?group_id=1&display_mode=1]]
I've created arrays before in other programming languages, but never had the occasion to do it in PHP before.We use PHP as programming language. So the syntax of PHP is mandatory to use. Other languages does not interest us.
...seems strange to me because I would think than in this case you would only want the comparison to return
I apologize for sloppy writing and calling them "comparative arrays". What I meant to say was that the symbols "=>" or "=" or "==" or "===" are all array *operators* that check the state of a variable and that in PHP each can return slightly different results depending on the types of fields being checked and a few other cases. As far as I can tell, "===" is considered the most accurate, but for most purposes "=>" works fine.
can someone help me? I want to show only the last three news on start-site ... to use the droplet is no problem - but the display-mode and css :-(
want to use a slider like display-mode 4 - but it's too height - it doesn't look very nice :-(
change the width, I was able to do.. but how can I change that it's not that high as original template?
div.newsslider1 .flexslider {
padding:15px 15px 15px 70px;
background: #DDEDED url(../images/news_bg.png) 10px 10px no-repeat;
}
.flexslider img {border: 2px solid #ffffff;}
here my code div.mod_anynews1 .flexslider {
max-width: 808px;
min-height: 100px;
background-color: #DDEDED;
border: 1px solid #00808E;
padding:0;
margin:0;
color:#000000;
}
src="{SYSVAR:MEDIA_REL}/you_image.jpg"
<div class="anynews">
<!-- BEGIN news_block -->
<div class="row">
<div class="col-1-3">
<div class="wrap-col">
<div class="item t-center">
<div class="item-container">
<tt></tt>{GROUP_IMAGE}<br />
</div>
<div class="item-info">
<hr />
<h3><tt></tt>{TITLE}<br /></h3>
<tt></tt>{CONTENT_SHORT}<br />
<tt></tt><p><a href="{LINK}">{TXT_READMORE}</a></p><br />
</div>
</div>
</div>
</div>
<!-- END news_block -->
</div>
<div class="anynews">
<div class="row">
<div class="col-1-3">
<div class="wrap-col">
<div class="item t-center">
<div class="item-container">
<tt></tt><br>
</div>
<div class="item-info">
<hr>
<h3><tt></tt>Заглание на новина 2<br></h3>
<tt></tt><p>Тук ще сложим анонса на новина две, който също ще ни послужи, за да видим как стои на екрана.</p>
<br>
<tt></tt><p><a href="http://localhost/iwork/pages/posts/zaglanie-na-novina-2-4.php">read more</a></p><br>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-1-3">
<div class="wrap-col">
<div class="item t-center">
<div class="item-container">
<tt></tt><br>
</div>
<div class="item-info">
<hr>
<h3><tt></tt>Заглавие на новина <br></h3>
<tt></tt><p>Анонс на новина тук! Трябва да има текси, за да се вижда как изглежда анонса и т.н.</p>
<br>
<tt></tt><p><a href="http://localhost/iwork/pages/posts/zaglavie-na-novina-3.php">read more</a></p><br>
</div>
</div>
</div>
</div>
</div> <div class="row">
<div class="col-2-3">
<div class="wrap-col">
<div class="slider">
<!-- Content- Left HERE -->
<div class="clear"></div>
</div>
</div>
</div>
<div class="col-1-3">
<div class="wrap-col">
<!-- Content- Right HERE -->
</div>
</div>
</div>
</div>
</div>
<tt></tt>{GROUP_IMAGE}<br />
$custom_placeholder = array('IMG_LINK' => '%img%', 'MY_VAR' => '#(test)#i'
{{ news.GROUP_IMAGE }}
displayNewsItems(
$group_id = 0,
$max_news_items = 6,
$max_news_lenght = -1,
$display_mode = 4,
$lang_id = 'BG',
$strip_tags = true,
$allowed_tags = '<p><a><img>',
$custom_placeholder = false,
$sort_by = 1,
$sort_order = 1,
$not_older_than = 0
);
$custom_placeholder = array('IMG_LINK' => '%img%', 'MY_VAR' => '#(test)#i'
<div class="anynews">
<!-- BEGIN news_block -->
<div class="row">
<div class="col-1-3">
<div class="wrap-col">
<div class="item t-center">
<div class="item-container">
<tt></tt>{GROUP_IMAGE}<br />
</div>
<div class="item-info">
<hr />
<h3><tt></tt>{TITLE}<br /></h3>
<tt></tt>{CONTENT_SHORT}<br />
<tt></tt><p><a href="{LINK}">{TXT_READMORE}</a></p><br />
</div>
</div>
</div>
</div>
<!-- END news_block -->
</div>
$set = @mysql_query ('SET NAMES utf8');
$set = @mysql_query ('SET COLLATION_CONNECTION=utf8_general_ci');
[[getNewsItems?group_id=2&display_mode=4&max_news_items=999&sort_by=1&sort_order=1&max_news_length=170&allowed_tags=<p><a><img><strong>]]
[[getNewsItems?group_id=1&display_mode=5&max_news_items=4&sort_by=1&sort_order=1&start_item=0¬_older_than=999&max_news_length=150]]
[[getNewsItems?group_id=1&display_mode=5&max_news_items=2&sort_by=1&sort_order=1&start_item=4¬_older_than=999&max_news_length=150]]