WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: cwsoft on February 11, 2012, 10:58:51 AM

Title: Snippet: cwsoft-anynews
Post by: cwsoft on February 11, 2012, 10:58:51 AM
Hello,

this post is to inform you about my trial to revive the support for the code snippet cwsoft-anynews (formerly known as Anynews).

Background information:
I took over responsibility for my previous modules "Anynews", "Addon File Editor" and "Postits" in February 2012, after maintenance has stagnated for more than 2 years and "modified" versions with small adaptions for latest WebsiteBaker or jQuery versions, and/or backwards incompatible changes (e.g. Anynews versions with changed function parameters) were spread around via the forum by other community members.

As a consequence, I "forked" my own modules (starting from the last official released version) at GitHub (https://github.com/cwsoft/wb-cwsoft-anynews) to give them a new home with a public repository for better code and feature request tracking and easier possibilities for contributions (via GitHub fork/pull mechanism etc.), instead of the very user unfriendly way of searching the forum for "patches" and "latest versions". With the initial releases at GitHub, I increased the major module version number to the next higher integer number to make the "fork" and the new start of maintenance support "visible".

Since February 2012, I pushed more than 60 commits (https://github.com/cwsoft/wb-cwsoft-anynews/graphs/impact) to GitHub and added 46k and removed 31k lines of code (including external plugins like Twig, file header changes etc.).

From February to September 2012 the following new features were included:
 - updated jQuery file inclusion to work with newer WB versions
 - added new jQuery slider plugin: "Flexslider"
 - made jQuery Plugins customizable without touching external plugin files
 - moved all hardcoded Anynews output to template files
 - fixed broken sort by comments feature added by another forum member
 - added option to filter news not only by group but also by: page, section, and post id
 - added option to filter news by page language
 - introduced the much more flexible template parser Twig
 - updated all templates to Twig
 - reworked entire README

Name change: "Anynews" --> "cwsoft-anynews"
In July 2012, I started to rename all my supported modules from "Module name" into "cwsoft-module-name". Since September 2012 all my modules stick to this naming convention.

The name change is finally a result of all the work I put into the "forked Anynews module" since February 2012, plus some branding with my domain cwsoft.de, plus the fact that "outdated" module versions (not supporting WB 2.8.x) are still listed at AMASP (http://www.websitebakers.com/pages/code-snippets/listings/anynews.php) without having control of updating the content as my request for a new AMASP account was refused, while receiving funny PMs or E-mails at the same time asking me to update those outdated modules.

Beside the name change, I dropped support for outdated PHP and WebsiteBaker versions. Hence modules following the "cwsoft-module-name" naming convention do need PHP 5.2.2 or higher and WebsiteBaker 2.8.x (starting from 2.8.2) as minimum requirement. Apart from that and the name change, nothing will change for you as a user or customer (beside the fact that you should uninstall a previous version so not to have two versions side by side). The modules are still published under the GNU GPL license (https://github.com/cwsoft/wb-cwsoft-anynews/blob/master/LICENSE.txt) and will be offered for free (as in free beer).

The sum of all that made me finally believe that a name change (including my branding cwsoft) is well justified. At the end it is the decision of the module author (which it's me) to choose an appropriate module name :wink:

Further information and downloads
 - Module README (https://github.com/cwsoft/wb-cwsoft-anynews#readme)
 - WebsiteBaker download packages (https://github.com/cwsoft/wb-cwsoft-anynews/downloads)
 - View or report known issues (https://github.com/cwsoft/wb-cwsoft-anynews/issues)

Feel free to contribute to the cwsoft-anynews module using GitHubs fork and pull mechanisms (http://help.github.com/send-pull-requests/).

Cheers
cwsoft
Title: Re: Codesnippet: Anynews
Post by: mdemaree99 on February 11, 2012, 09:57:11 PM
Please update the jquery  to use the normal 1.3.2 file vs modified file.

Currently if another module uses the real jquery 1.3.2 functions there are compatibility issues due to the differences..
Title: cwsoft-anynews - next steps
Post by: cwsoft on February 11, 2012, 10:12:23 PM
Hello,

plans for the next release are:
 - remove jquery 1.3.1 version shipped with the module and use the WB version instead (WB 2.8.2 --> jQuery 1.7)
 - check compatibility of jQuery plugins with jQuery 1.7
 - check for alternative plugins supporting jQuery 1.7+
 - remove jQuery support from Anynews if no alternative slider working with jQuery 1.7 is found

Cheers

P.S.:  Seems the jQuery coda-slider plugin is no longer actively maintained (last commit 2009, required jQuery 1.3.1). Due to massive API changes from jQuery 1.3 to 1.7, I doubt that the coda-slider plugin will work with jQuery 1.7 without massive changes. So if I do not find a compatible plugin, I tend to remove it from Anynews.
Title: cwsoft-anynews
Post by: cwsoft on February 12, 2012, 01:03:59 AM
Hello,

cwsoft-anynews ships with the third Party JQUERY Plugin Coda-slider, which seems no longer be actively developed. The Last Update was 2009 and requires jQuery 1.3.1. WB 2.8.2 ships with jQuery 1.7, which is incompatible to 1.3.1.

The question is, how many people Out there are Using this anynews feature and how many of the People using this Feature have issues? Is there an alternative for Coda-slider, licensed under GPL and Running with JQuery 1.7+?

Are there any cracks Out there willing to Update the Coda slider jQuery stuff? The answers will help to figure Out if this Feature will be Removed with the next version or Not.

Cheers
Title: Re: Codesnippet: Anynews
Post by: kweitzel on February 12, 2012, 12:34:26 PM
I personally do use AnyNews but without the coda slider. The second one mostly because I never got it working to my satisfaction  :roll:

Cheers

Klaus
Title: Re: Codesnippet: Anynews
Post by: jacobi22 on February 12, 2012, 03:02:26 PM
i used coda-slider in my test-space - with jquery 1.71, no Problems

Title: Re: Codesnippet: Anynews
Post by: mdemaree99 on February 13, 2012, 05:39:46 AM
I am using the Anynews with coda slider

The update will be great and should get rid of many of the compatibility issues with other modules.

Another nice to have as  long as the coda slider is working.
Can you change the input box to match up with the height  for the Short: description?
Allows users to know exactly how much room they have to work with when building a slide.

I originally modified my anynews for the height and ideally I would change width also, but this changes up the editor up a little to much for my taste.

I did have one issue.  After changing the height, it seems I get an error message(everything works correctly even with error to m knowledge) when I change the title of the slide.  Not sure if they are related, but only started getting message after I changed height of short description. 

[gelöscht durch Administrator]
Title: cwsoft-anynews v2.1.0 ALPHA (FOR TESTING PURPOSE ONLY)
Post by: cwsoft on February 15, 2012, 10:22:01 PM
Hi,

uploaded a first ALPHA version of the upcoming cwsoft-anynews version 2.1.0 on GitHub (https://github.com/cwsoft/wb-cwsoft-anynews/downloads)

The version is written for the WB 2.8.x series only, starting from WB 2.8.2 and intended to be tested by more experienced users at a first place. The version is NOT YET ready for productive sites.

Apart from code restructuring, the handling of Javascript files was modified to make use of the mechanismns introduced with WebsiteBaker 2.8.1/2.8.2. In addition two new jQuery sliding effects were added: "coda-slida-2.0" and "flexslider" (set display_mode = 3,4 or 5).

To make the jQuery slida effect working, one needs to add the following code into the head section of the index.php of the frontend template:

Code: [Select]
<?php
if (function_exists('register_frontend_modfiles')) {
register_frontend_modfiles('css');
register_frontend_modfiles('jquery');
register_frontend_modfiles('js');
?>


Note: CSS styling and parameters of the slida effects can be modified by the files located in folders css and javascript. The jQuery plugin files in the folder thirdparty should not be modified unless there is a real need for it.

Feedback welcome.

Cheers
Title: Re: Codesnippet: Anynews
Post by: DarkViper on February 15, 2012, 10:41:56 PM
a little hint:
if (function_exists('register_frontend_m odfiles')) {
is never needed since 2.8.1. The funktion is included in the core now and always available for templates.  8-)
Title: Re: cwsoft-anynews
Post by: cwsoft on February 15, 2012, 11:06:40 PM
Well I know, but as all templates shipped with WB 2.8.2 und 2.8.3 still include this, I decided to copy it over.
Its easier for me to explain to search for that code in the template and refer to Default templates, than trying to teach the right way off doing it :-)

Cheers
Title: cwsoft-anynews 2.1.0 - which jQuery slider plugin to implement ??
Post by: cwsoft on February 19, 2012, 07:53:38 PM
Hello,

I want to update the jQuery sliding/fading effect for the upcoming cwsoft-anynews version 2.1.0.

So far anynews ships with a jQuery effect called better-coda-slider (http://jqueryfordesigners.com/coda-slider-effect/), which is a free rebuild of the commercial Panic - Coda slider (http://www.panic.com/coda/). As the "better-coda-slider" has a lot of dependencies to other jQuery plugins and is no longer actively developed, I decided to drop it in favour of another jQuery plugin.

So far I have reviewed the following candidates:
 - flexslider (http://flex.madebymufffin.com/) (my favorite so far, Open Source, last update Oct. 2011)
 - coda-slider-2.0 (http://www.ndoherty.biz/tag/coda-slider/) (GPL, but last update 2009)
 - innerfade (http://medienfreunde.com/lab/innerfade/) (simple plugin, but last update from 2008)

Before I pick one jQuery slider plugin, I would like to ask YOU, if YOU:
 - know a better slider which is actively maintained, licensed under GNU (or equivalent), works with jQuery 1.7
 - want to share your expertise in styling the slider to look good in Anynews (e.g. buttons, boxes, ...)

If you want to suggest another slider which fulfills above requirements and/or want to add your hands on the final CSS layout for the slider shipped with the upcoming cwsoft-anynews (credits will be given), please post in this thread or send me a PM.

Deadline for your suggestions and/or help offers is 26th Feb. 2012 (one week from now). After that date I will carry on with the development of cwsoft-anynews v2.1.0.

Cheers

P.S.: To get an impression of how jQuery effects will be integrated into Anynews 2.1.0, you may want to download and test the first ALPHA version announced in post 7 (https://forum.WebsiteBaker.org/index.php/topic,23355.msg158360.html#msg158360) of this thread. The ALPHA version includes all slider effects except the innerfade slider mentioned above.
Title: Re: Codesnippet: Anynews
Post by: mdemaree99 on February 20, 2012, 04:27:02 AM
Flexslider looks good as long as it works with Anynews.  I only see it working with images.
Already a fan of codaslider...
Couldn't get the link to innerfade work.

Another simple jq option is  http://bxslider.com/ (http://bxslider.com/)
Not sure on the last time it was updated though.
Title: Re: Codesnippet: Anynews
Post by: dbs on February 20, 2012, 08:57:14 AM
Old and good are also cycle-plugin http://jquery.malsup.com/cycle/ (http://jquery.malsup.com/cycle/).
I use it for Anynews.

Another is jcarousellite http://www.gmarwaha.com/blog/2007/08/09/jcarousel-lite-a-jquery-plugin/ (http://www.gmarwaha.com/blog/2007/08/09/jcarousel-lite-a-jquery-plugin/)
Used as Bakery-Item-Slider.

Both works with jquery 1.7.1, supports pause on mouseover, endless scroll and more.
Title: Re: cwsoft-anynews
Post by: cwsoft on February 20, 2012, 04:18:48 PM
Hello,

thanks for your feedback so far, see my comments below.

Quote from: mdemaree99
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).

Quote from: mdemaree99
Already a fan of codaslider...
Guess you are talking about coda-slider-2.0 (http://www.ndoherty.biz/tag/coda-slider/) - right?
Only issue I have with this plugin is that it seems not actively maintained (last update from Oct. 2009).

Quote from: mdemaree99
Couldn't get the link to innerfade work.
The link posted below works for me. Maybe do a Google search for "innerfade jQuery".

Quote from: dbs
Old and good are also cycle-plugin
Thanks for the link, will have a look on this plugin.

Quote from: dbs
Another is jcarousellite
As this Plugin is not actively maintained (last update 2007) I doubt it will make it into cwsoft-anynews.

Cheers
Title: cwsoft-anynews v2.1.0 STABLE - Released
Post by: cwsoft on February 29, 2012, 06:10:57 PM
Hi,

just released cwsoft-anynews V2.1.0 STABLE at GitHub. The latest version requires WebsiteBaker 2.8.2 (recommended last stable 2.8.x version) und PHP 5.2.2 (recommended last stable 5.3.x version).

Changes compared to cwsoft-anynews v2.0.0
Third party code was moved into a separate subfolder. Integration of custom Javascript or jQuery plugins was simplified. The additional jQuery slider effect plugin "flexslider" was added as alternative to the outdated "better-coda-slider" distributed with Anynews.

Location and naming of template files have changed from /htt/custom_display_mode_X.htt to /templates/display_mode_X.htt. The Anynews cheat sheet template providing an overview of all Anynews template placeholders is now displayed via $display_mode = 99 (before $display_mode = 4). The HTML output of the Anynews template files is now wrapped in a div with class mod_anynews to avoid clashes with other modules, templates or WebsiteBaker CSS definitions.

Links
README (https://github.com/cwsoft/wb-cwsoft-anynews#readme)

Cheers cwsoft
Title: Re: Codesnippet: Anynews
Post by: Argos on March 03, 2012, 10:27:04 PM
Nice to see someone actively maintaining this often used snippet. Thanks for your efforts.

It would be nice to see offical section support added to it, besides groups support. There is a hack somewhere on the forums that shows how to use AnyNews with section ID, but that never made it into the official module. I believe few people use groups in News, most people would just use separate sections to show News about different subjects.
Title: cwsoft-anynews v2.2.0 RC1 - available
Post by: cwsoft on March 04, 2012, 08:47:08 PM
Hello,

issued a first release candidate (RC1) of the upcoming cwsoft-anynews v2.2.0 at GitHub (https://github.com/cwsoft/wb-cwsoft-anynews/downloads).

This version includes three improvements and additional features requested by forum users:
 1. the hardcoded "no news available" text can now be styled or removed via Anynews template files
 2. the flag $lang_filter allows to remove news entries not matching the defined $lang_id
 3. values of group_id can now be linked to group_id, page_id, section_id or post_id

Apart from that a bug in the language file inclusion of v2.1.0 was fixed.

The cwsoft-anynews v2.2.0 function signature has changed as follows:
The last two parameter are new and where added to the end of the function to not break older Anynews function calls. Paramter $group_id_type defaults to "group_id", paramter $lang_filter to false, which is the default behaviour of previous Anynews versions.

Code: [Select]
<?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)
);

Setting $lang_filter = true shows only news items added from a news page which LANGUAGE type matches $lang_id. If no news page exist for this LANGUAGE, all news entries will be shown instead.

Feedback welcome.

Cheers
Title: Re: Codesnippet: Anynews
Post by: Argos on March 04, 2012, 08:53:12 PM
Looks very nice. Great to see the section-ID, page-ID and post-ID support added!
Title: cwsoft-anynews - translation needed
Post by: cwsoft on March 05, 2012, 07:18:39 PM
Hi,

forgot to mention that I do need some help in updating some cwsoft-anynews text outputs into the following languages: Estonian (EE.php), French (FR.php), Dutch (NL.php), Serbian (RS.php) for Anynews 2.2.0 stable.

English phrases which needs to be translated into languages above:
a) "For details please visit " GitHub. (GitHub needs no translation)
b) "Number of comments"

Would be great if a native speaker could review the cwsoft-anynews language files listed above for possible misspelling or grammar issues. You can post your translation/updates in this thread or send me a PM.

Thanks in advance
cwsoft
Title: Re: Codesnippet: Anynews
Post by: Argos on March 05, 2012, 09:10:38 PM
Will do for Dutch.
Title: Re: cwsoft-anynews
Post by: cwsoft on March 05, 2012, 10:59:52 PM
@argos: thanks for your offer, looking forward to implement the updated NL files
Title: Re: Codesnippet: Anynews
Post by: Argos on March 06, 2012, 10:20:24 PM
Here's the Dutch language file:

Code: [Select]
<?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)'
);
Title: Re: cwsoft-anynews
Post by: cwsoft on March 07, 2012, 05:34:57 PM
Thanks Argos, highly appreciated.
Title: Re: Codesnippet: Anynews
Post by: mdemaree99 on March 07, 2012, 07:09:13 PM
Is anybody else is having issues with the new module using the sliders?

In both the coda and flex sliders I get about a 5 second delay / lag before the slider starts working.
Had similar issues in previous version with coda, but it wasn't as bad (maybe 1-2 sec)

I have included the screen shots.  Top is initial image that is shown for about 5 sec on coda and a little longer in flexslider.  It may be the same time, but seems longer with nothing showing on the screen.

After a little testing..I thought this may be tied to the interval or duration, but changing values just seemed to shorten or lengthen after the slider actually appeared.  Still had about a 5 sec delay.  Are these scripts really this slow?  Possible compress to run faster?  Any other values I may be missing?

On a side note..I was was looking at the js files.  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.
Would suggest separating a few of the settings to the custom js file.



 




[gelöscht durch Administrator]
Title: Re: cwsoft-anynews
Post by: cwsoft on March 07, 2012, 07:36:32 PM
Hi,

could you please provide the infos listed at the bottom of the cwsoft-anynews README (https://github.com/cwsoft/wb-cwsoft-anynews#readme) file? In addition please provide details on your browser, browser version. A link to a live side would be helpfull if available.

Tested cwsoft-anynews with Firefox 10.2 with better-coda-slider and flexslider at one page. Both news show up immediatelly and react independant of each other without issues. If you are using more than one slider effect per page, try to reduce it to one sliding effect per page and check if that solves your issue. Don't know if files included via jQuery $.insert plugin are cached, as done with files included e.g. via link statements in the head section of a HTML file. If you still experience issues, try to check the loading / request time with browser tools like Firebug to identify the bottle neck.

Quote
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:

Cheers

[gelöscht durch Administrator]
Title: Re: Codesnippet: Anynews
Post by: mdemaree99 on March 08, 2012, 01:02:48 AM
I tested like you did and just put the slider on a page by itself.
Along with testing 3 other templates I still get a lag.  However I am noticing I may have some errors in my templates.  They are working fine in the actual website, but when I created the testing area  things aren't quite loading up correctly for some reason.  (code sections are looking funny)  Fine on rest of my pages.  Not sure what is up.


Testing site:
Main page is www.jlarlington.org/jlabaker  (http://www.jlarlington.org/jlabaker) and has the biggest lag.
Tons of stuff on this page so I can see why it takes a big, but nothing else seems to load up slow.
I made a few test pages for Anynews here:
http://www.jlarlington.org/jlabaker/pages/testing/anynews-testing.php (http://www.jlarlington.org/jlabaker/pages/testing/anynews-testing.php)

Test pages aren't to bad, but just the module by itself.
Test 1 is the fastest with the CSS
Templates do have the testing to see if something contains data. 
I believe that has given a few modules problems..
Code: [Select]
<?php
        ob_start
();
        
show_menu2(0SM2_CURR+1SM2_CURR+1);
        
$childmenu ob_get_contents();
        
ob_end_clean();
?>


Test 2 and 3 are about the same.
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.
Not quite sure why it is taking forever to load. 

For the time being I put a small work around in.  I changed overflow to hidden in the better-coda-slider.css
By updating the   .scroll  thescroll-bar so it just appears 1st slide is active longer than the rest and then the arrows appear.  Just need to tweak for final output.

.scroll {
   height: 150px;
   width: 450px;
   overflow: hidden;
   overflow-x: hidden;
   position: relative;
   clear: left;
   background: #FFF url(images/content_gradient.gif) repeat-x scroll left bottom;



Detailed error description (what happens, what have you tried ...)
- lag..of 2-5 sec before slider is active

Anynews version (go to WebsiteBaker section Add-ons / Info / Anynews)
Anynews 2.2.0-RC2


PHP version

PHP Version 5.2.11

System    
Windows NT IIS01801 5.2 build 3790    
Know the windows server is a big killer for me..

WebsiteBaker version
Revision 1528
Admin version 1.6

WebsiteBaker frontent template
- Custom templates - Initial glassbury and simplecss.

Changes you made to WebsiteBaker
- No changes to WebsiteBaker, but had to make a minor change to library-admin due to the windows server.

Browsers:
Firefox 3.6.24 and Internet explorer 8 and 9


Thanks for the info on firebug.  I was searching the web for online items to speed it see where the bottleneck was.  Always good when the solution is free.l
Title: Re: cwsoft-anynews
Post by: cwsoft on March 08, 2012, 06:53:02 PM
@mdemaree99

Thanks for the exhaustive details.

Quote from: mdemaree99
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.

According the Firebug Network protocoll, your main page (the one with the biggest lag) has a lot of HTTP request (43) and needs about 14 seconds to load all files. Your main site needs 8s until the DOM is ready, which is the trigger to fire up the jQuery stuff. So before the jQuery slider starts working, it takes at least 8s time to load all the content of your main site. To load all Javascript and CSS files takes about 6s.

The "better-coda-slider" consumes 7 HTTP requests (5 to load the original JS and CSS files) and another two for the customized JS and CSS. In total the "better-coda-slider" consumes around 4.4 seconds loading time. Flexslider needs less requests and resources. As the "better-coda-slider" tries to be unobstrusive, it displays the slider icons (left, right arrows) only if Javascript is enabled AND the DOM is ready. This could be used as a sort of visual measure for load optimization.

I doubt that Anynews is the real issue maker here. I would contact your webhosting company and ask for advice. The long loading time until the PHP infos are displayed and the 8s to get the DOM ready seems quite long. If you want to have a sort of protocoll with elements, requests, file size and loading time, you can use other online services as well, such as http://analyze.websiteoptimization.com

Sorry, think I can't really help you on that issue.

Cheers
Title: cwsoft-anynews v2.2.0 STABLE - released
Post by: cwsoft on March 09, 2012, 08:39:45 PM
Hello,

just released cwsoft-anynews V2.2.0 STABLE at GitHub.

Minimum requirements:
 - WebsiteBaker 2.8.2 (recommended last stable 2.8.x version)
 - WebsiteBaker news module installed
 - PHP 5.2.2 (recommended last stable 5.3.x version)

Updates since cwsoft-anynews v2.1.0
 1. hardcoded "no news available" text can now be customized from the template files
 2. new flag $lang_filter allows to remove news entries not matching the defined $lang_id
 3. now possible to filter news by group_id, page_id, section_id or post_id
 4. included updated Dutch language file (thanks to forum user Argos)

Cheers
Title: Re: Codesnippet: Anynews
Post by: sky writer on April 11, 2012, 02:57:32 AM
One of the features I like about the News module is the pagination.  But I have a site where there are a bunch of News sections which we want to show combined on one page, so AnyNews seems perfect EXCEPT it does not paginate, so we either have to choose the number of news items we want to allow on the page (for example 10) and then anything older than that is no longer accessible, or we have to set the limit to zero so that all (could be hundreds) news items show.

Is there any way that this pagination feature could be integrated into AnyNews?
Title: Re: cwsoft-anynews
Post by: cwsoft on April 11, 2012, 08:54:22 AM
Hello,

Quote from: sky writer
Is there any way that this pagination feature could be integrated into AnyNews?
Of course, everything can be integrated :wink:

The easiest way without modifying the Anynews code itself is to create a custom template, which implements one of the free available jQuery Paginator Plugins (http://www.jquery4u.com/plugins/10-jquery-pagination-plugins/).

Create a template with jQuery Smart-Paginator Plugin:
 1. download jQuery Smart Paginator (http://www.egrappler.com/jquery-pagination-plugin-smart-paginator/)
 2. copy the CSS and Javascript files to cwsoft-anynews/thirdparty/smartpaginator
 3. create a copy cwsoft-anynews/templates/display_mode_4.htt --> e.g. display_mode_5.htt
 4. adapt CSS / JS inclusion to load the paginator files
 5. change Anynews template according the Smart Paginator example (smartpaginator.htm)

Another option is to organize the news you want to display in groups and to use the WebsiteBaker news module instead of cwsoft-anynews.

Hope this helps.

Cheers
Title: Re: Codesnippet: Anynews
Post by: daydreamer on May 01, 2012, 03:43:31 PM
Thanks for the update of anynews, one question is it possible to truncate the title?

Thanks
Title: Re: cwsoft-anynews
Post by: cwsoft on May 01, 2012, 08:31:42 PM
Hi,

Quote from: daydreamer
... 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).

Another option is to add this feature to your cwsoft-anynews module code by wrapping the PHP function substr (http://php.net/manual/en/function.substr.php) around this code line (https://github.com/cwsoft/wb-cwsoft-anynews/blob/master/include.php#L249) as shown below (replace X with numbers of characters to show):
Code: [Select]
'TITLE' => substr(($strip_tags) ? strip_tags($row['title']) : $row['title'], 0, X),

Future planning:
With the next major cwsoft-anynews release (most likely with WB 2.9 if not covered by the core itself), Anynews will provide a more flexible customization using a config object instead of optional function parameters and switch the template engine to something more flexible, allowing loops, if statements or truncation in the template itself (switched to Template engine Twig with cwsoft-anynews v2.3.0). This step should solve most "architectural limitations" of todays Anynews snippet.

For the time beeing, you have to implement one of the two solutions above by your own - sorry  :wink:

Update 16th May 2012
Since cwsoft-anynews v2.3.0, the above feature request can easily be realized via a customized template:
Code: [Select]
{{ news.TITLE | slice(0,X) }}

Cheers
Title: Re: Codesnippet: Anynews
Post by: marmot on May 01, 2012, 09:20:36 PM
Hi,
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.

regards
Title: Re: Codesnippet: Anynews
Post by: daydreamer on May 01, 2012, 10:24:48 PM
Thanks guys for the help
Title: Re: Codesnippet: Anynews
Post by: daydreamer on May 01, 2012, 10:33:49 PM
@cwsoft this works great

Code: [Select]
'TITLE' => substr(($strip_tags) ? strip_tags($row['title']) : $row['title'], 0, X),
Thanks
Title: cwsoft-anynews v2.3.0 STABLE - released
Post by: cwsoft on May 05, 2012, 02:43:32 PM
Hello,

just released cwsoft-anynews v2.3.0 STABLE at GitHub.

This release replaces the outdated phplib template parser with the more flexible, fast, maintained and well documented template parser Twig (http://twig.sensiolabs.org/). For convenience, Twig is distributed with cwsoft-anynews (thirdparty folder). All templates where updated and work like in previous releases.

The more flexible template parser allows to implement most of the recent requested features by the template itself and hence without touching the module code. If you want to learn more about Twig, visit http://twig.sensiolabs.org/doc/templates.html

Infos & Download
 - README (https://github.com/cwsoft/wb-cwsoft-anynews#readme)
 - download latest installation package (https://github.com/cwsoft/wb-cwsoft-anynews/downloads)
 - view or post known issues (https://github.com/cwsoft/wb-cwsoft-anynews/issues)

Feedback welcome.

Cheers
Title: Re: Codesnippet: Anynews
Post by: Stefek on May 06, 2012, 10:25:02 PM
Hello,
I have a suggestion to make which will make this snippet even more user friendly.

In file include.php
LINE 75

suggestion:
Code: [Select]
<?php // ignore opening tag

$loader = new Twig_Loader_Filesystem(array(WB_PATH.'/templates/' .TEMPLATE'/anynews'dirname(__FILE__) . '/templates'));

and 83 ff.

Code: [Select]
<?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');
}

The snippet will look into my template (the template of the page) first, before it will look into the templates/ directory of anynews. Thus you have the opportunity to even ship the "skin" (template) of anynews together with the WebsiteBaker-template.


Kind regards,
Christian
Title: Re: cwsoft-anynews
Post by: cwsoft on May 06, 2012, 11:44:46 PM
Hello,

thanks for your suggestion.

Not too sure if this is really a benefit with respect to "simplicity" in mind or adds more confusion for new users (e.g. CSS is still one single file located in anynews/css). I also doubt that there are many use cases for this feature (at least in this form).

Anyway, if more users do see a need for this feature and request to implement it, I will think about adding it to one of the next Anynews release.

cwsoft
Title: Re: Codesnippet: Anynews
Post by: Stefek on May 06, 2012, 11:52:12 PM
OK.

I got it implemented since some time.
The new template engine supports the inclusion from different sources even better.

Regards,
Stefek
Title: Re: Codesnippet: Anynews
Post by: DarkViper on May 07, 2012, 02:02:41 AM

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');
}

to make it a little bit more easy... ;-)
Code: [Select]
<?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');
}

only if really no template file is found, an exception will be thrown.
Why not use the possibilities of OOP...  ;-)
Title: Re: Codesnippet: Anynews
Post by: Stefek on May 07, 2012, 04:04:16 PM
Cool Werner,
that's even better.

// EDIT

But there is still a problem with the implementation.
Not any TEMPLATE will have the 'anynews' directory and it's not possible to make in mandatory within TEMPLATEs in order to run the anynews snippet (not anyone will like the idea to "patch" his TEMPLATE in order to use the snippet).

How can I code a statement that the $loader should add the WB_PATH.'/templates/'.TEMPLATE.'/anynews' directory at the beginning at the array ONLY if the directory exists?
Using my current knowledge I wold do it in this way:

Code: [Select]
<?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($aLoaderDirWB_PATH.'/templates/' .TEMPLATE'/anynews');
}

$loader = new Twig_Loader_Filesystem($aLoaderDir);



but I am sure there is another way, more convenient and cleaner.

KR,
Stefek
Title: Re: Codesnippet: Anynews
Post by: DarkViper on May 07, 2012, 04:26:32 PM
A little bit shorter:   ;-)

Code: [Select]
<?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 possibilities. ;-)
Title: Re: Codesnippet: Anynews
Post by: Argos on May 07, 2012, 04:33:36 PM
It seems the AnyNews module/snippet is becoming more advanced and complex than the News module itself... Isn't it better to put the effort into the core module itself? It could use a whole lot of improvement, like custom fields, pagination in backend, image support, more flexible backend and frontend ordering, etc.
Title: Re: Codesnippet: Anynews
Post by: Stefek on May 07, 2012, 04:47:33 PM
Thanks Werner. That's what I thought should be possible.
Quote
Have a look inside the class documentation (or the classes itself). You will find an endless bunch of possibilities
I will.

@Argos
I think the Modules will evolve into the right direction soon.

Kind Regards,
Stefek
Title: Re: Codesnippet: Anynews
Post by: DarkViper on May 07, 2012, 05:27:24 PM
It seems the AnyNews module/snippet is becoming more advanced and complex than the News module itself...

Jurgen, thats right. And it's really good in this way.
The Basic module provides the Basics...  and other Modules extends them.
It's the sense of modular design.
In future WB shall become much more modular then now. - but with clear rules how to do and a predefined structure too -
 
Title: Re: Codesnippet: Anynews
Post by: Argos on May 07, 2012, 05:37:00 PM
I really meant that the News module input/backend options and flexibility are getting less attention than output/frontend options, which is for me the wrong focus. The core module lacks powerful possibilities, and is essentially the same as it was in version 2.6.4, when I first started working with WB. Again and again I find myself struggling with missing essential features in WB. I am seriously testing Wordpress and other systems now because I cannot move forward with WB in certain directions. It's perfect for rather simple, semi-static sites, but above that it's lacking severely in ithe kind of flexibility and power I need for bigger clients.

But that's another matter, we should not really discuss here. It's great to see AnyNews being developed.
Title: Re: cwsoft-anynews
Post by: cwsoft on May 07, 2012, 06:31:58 PM
Hi,

@Stefek: Details about Twig (including all the hints from Werner below like try, except, multiple templates) can be found in the Twig PDF (http://twig.sensiolabs.org/pdf/Twig.pdf) (129 pages). As starting point, just work through the official documentation (http://twig.sensiolabs.org/documentation)

Quote from: argos
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.

Quote from: argos
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:

Quote from: argos
I really meant that the News module input/backend options and flexibility are getting less attention than output/frontend options
Some 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.

Cheers
Title: cwsoft-anynews v2.4.0 STABLE released
Post by: cwsoft on May 08, 2012, 05:55:06 PM
Hello,

just released cwsoft-anynews v2.4.0 STABLE at GitHub.

Updates since cwsoft-anynews v2.3.0
 1. added compatibility fix for the upcoming WB 2.8.3 hotfix (thanks to ruebenwurzel for the notice)
    (Background: with WB 2.8.3 SVN #1688, Twig is part of the WB core and will be registered by default)
 2. this release ensures that Anynews works on WB 2.8.2 and all 2.8.3 versions as usual

Cheers
Title: Re: Codesnippet: Anynews
Post by: Argos on June 06, 2012, 03:46:18 PM
Small but important Dutch language file fix:

Change line:
'DATE_FORMAT'            => '  (d-m-Y, H:M')
into:
'DATE_FORMAT'            => ' d-m-Y, H:i'

An 'M' stands for 'month', while an 'i' stands for 'minutes'. An i is of course required here, instead of an M.

I also left out the () and the leading space in that line. It's markup, and should be added in the template files if wanted.
Title: Re: cwsoft-anynews
Post by: cwsoft on June 06, 2012, 07:38:53 PM
Hi Argos,

thanks for your notice. Already fixed this on Github, so it will be issued with the next Anynews version.

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. According the PHP date manual (http://php.net/manual/function.date.php), H:M should be replaced with H:i, not as you proposed with [H:m]  :wink:
[EDIT by argos: I changed my post above to prevent mistakes]

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.

Cheers
Title: Re: Codesnippet: Anynews
Post by: Argos on June 06, 2012, 09:39:01 PM
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.

Sorry about this mistake! I just accidentally noticed it when I used your updated AnyNews in a new site.

Quote
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.

In this site I put the date under the title, like in the screenshot. So that's why I removed the (). No need for them there. I can imagine other people don't need them either, so that's why I think it's best to put them in the template. It cost me about 30 minutes to find out that they were part of the language file...

[gelöscht durch Administrator]
Title: Re: cwsoft-anynews
Post by: cwsoft on June 06, 2012, 09:46:43 PM
Hi Argos,

Quote from: Argos
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?

Quote
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.
 
Cheers
Title: Re: Codesnippet: Anynews
Post by: Argos on June 06, 2012, 09:51:31 PM
You're right twice  :-D
Version 2.40, and I never used the date before. Most of the times I just show a list of links without dates, short content and read more links.
Title: cwsoft-anynews v2.5.0 STABLE
Post by: cwsoft on July 01, 2012, 05:47:27 PM
Hello,

just released cwsoft-anynews v2.5.0 STABLE at GitHub.

Updates since cwsoft-anynews v2.4.0
 1. moved whitespace and brackets from LANG files into TEMPLATE files (thank to Argos)
 2. fixed wrong date format in the Dutch language file (thanks to Argos)
 3. renamed module from anynews into cwsoft-anynews
 4. updated repository structure

PLEASE NOTE: Please delete any possible existing previous Anynews version via the WebsiteBaker backend BEFORE installing the new version.

Cheers
Title: Re: Codesnippet: Anynews
Post by: N1kko on July 25, 2012, 11:46:48 PM
Thanks I use use anynews alot much appreciated  :-D
Title: Re: Codesnippet: Anynews
Post by: babsy on August 10, 2012, 09:03:02 PM
Hi

I was just wondering if it was possible to (exclude one group), if I have many different pages with news items, and I want them all to show up in the main page, but since I want one more "anynews" code to be just for one group (the main story, wich has more text etc.) Is this possible? I just can´t seem to figure that out.

it would be like this:

MAIN STORY (one special group id)
text, text, text, text, text, text, text
text, text, text, text, text, text, text
text, text, text,text, text, text,

SMALL STORY 1 (all the rest of the group id´s)
text, text, text, text, text, text,

SMALL STORY 2 (all the rest of the group id´s)
text, text, text, text, text, text,
Title: Re: cwsoft-anynews
Post by: cwsoft on August 11, 2012, 09:14:00 AM
Hi,

Not sure I really got what you are after, but you could try the following:

- call three times the anynews function
- first call set groupid you want and limit output to one news entry
- second call with all the other groups but without the first

You can create different templates for the three calls if you need. Check out the README at GitHub, especially the section explaining the parameters at https://github.com/cwsoft/wb-cwsoft-anynews#readme. The parameters $group_id and $group_id_type allow you to define the groups, sections or pages from where you want news to display.

Cheers
Title: Re: Codesnippet: Anynews
Post by: babsy on August 11, 2012, 06:49:24 PM
Hi

Yes I know what you mean, I have just tried a new code:

echo "<div id=\"anynews1\">";
if (function_exists('displayNewsItems')) {
   displayNewsItems((11,13), 1, -1, '','', '', '', '','', '','');
}
echo "</div>";

But I get an error when i have two groups (11,13) so I must being doing something wrong in the code?
Since the same code works just fine, when I use just one group-id (11 or 0 and so on) - but as soon as there are multible group-id, (from different pages) I get an error.

any ideas?
Title: Re: cwsoft-anynews
Post by: cwsoft on August 11, 2012, 09:34:42 PM
Hi Babsi,

Quote from: Babsi
displayNewsItems((11,13), 1, -1, '','', '', '', '','', '','');
This code won´t work.

Please try to call ONE Anynews function with the default parameters (https://github.com/cwsoft/wb-cwsoft-anynews#anynews-parametes). If this works, try to change the group id using $group_id = array(11,13) as explained in the function parameter list. If this works, then you can adapt the other parameters. Doing one step at once often helps to identify the issue :-)

As I am in vacation right now, I won´t be able to help any further with this for the next week or so.

Cheers cwsoft

Title: Re: Codesnippet: Anynews
Post by: babsy on August 11, 2012, 11:07:24 PM
Hi

Thanks for the help -  I have tried this now:

echo "<div id=\"anynews1\">";
if (function_exists('displayNewsItems')) {
   displayNewsItems(
 $group_id = 14,
    $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
   
   );
}
echo "</div>";

and it works fine for one group or with "0", but as soon as I set multible group-id´s im in trouble, i have tried these possible codes for group-id:

$group_id = 14.16,
- but then it just showes the first one, 14, and if i change them  16.14, (16 is the only one to show)


$group_id = (14,16),

$group_id = array(14,16)
- then this error message come:
"Parse error: syntax error, unexpected T_VARIABLE in /home/admin/domains/domain/public_html/modules/code/view.php(32) : eval()'d code on line 5"

$group_id = 14,16,
- then it just says "No news available"

I can´t seem to get what I´m missing here  :|
Title: Re: Codesnippet: Anynews
Post by: Ruud on August 11, 2012, 11:11:47 PM
$group_id = array(11,13)
Note the word "array".
Title: Re: Codesnippet: Anynews
Post by: babsy on August 11, 2012, 11:13:20 PM
Yes i tried both with the word array and without, but still i get this message:

Parse error: syntax error, unexpected T_VARIABLE in /home/admin/domains/mydomain/public_html/modules/code/view.php(32) : eval()'d code on line 5

Title: Re: cwsoft-anynews
Post by: cwsoft on August 12, 2012, 10:51:14 AM
@babsi: Can you try the following:

a) uninstall the cwsoft-anynews code snippet via WebsiteBaker backend (just the snippet)
b) install latest version 2.5.0 from Github (https://github.com/cwsoft/wb-cwsoft-anynews/downloads)
c) try again

Don't have access to a working testing environment, so I can't test if there is any regression in cwsoft-anynews itself (hope not), causing this issue.

Cheers
Title: Re: Codesnippet: Anynews
Post by: marmot on August 12, 2012, 11:01:42 AM
Hi,

sorry for interfere here but looking at this
$group_id = array(14,16)
and  the error message I would assume there is just a comma missing: 
Code: [Select]
$group_id = array(14,16),
regards
Title: Re: Codesnippet: Anynews
Post by: babsy on August 12, 2012, 03:20:54 PM
Hi, and thanks  :-) yes, that was the one, i have tried it before, i see. But i must have made some other mistake. Sorry for the mess.

All workes fine now, with multible groups, like this:

echo "<div id=\"anynews\">";
if (function_exists('displayNewsItems')) {
   displayNewsItems(
$group_id = array(14,16),
    $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
   
   );
}
echo "</div>";
Title: cwsoft-anynews 2.6.0 STABLE released
Post by: cwsoft on August 29, 2012, 09:33:08 PM
Hello,

just released cwsoft-anynews v2.6.0 STABLE at GitHub.

Updates since Anynews v2.5.0
 1. finalized module re-naming into cwsoft-anynews
 2. renamed GitHub repository into wb-cwsoft-anynews (so update possible bookmarks)

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.

Infos & Download
 - Anynews README (https://github.com/cwsoft/wb-cwsoft-anynews#readme)
 - download latest installation package (https://github.com/cwsoft/wb-cwsoft-anynews/downloads)
 - view or post known issues (https://github.com/cwsoft/wb-cwsoft-anynews/issues)

Feedback welcome.

Cheers
Title: Re: Codesnippet: Anynews
Post by: Bug on August 30, 2012, 07:51:36 AM
Why the stupid name change?
Title: Re: cwsoft-anynews
Post by: cwsoft on September 03, 2012, 04:58:42 PM
Hi,

Why the stupid name change?
Just curious. Is there any special reason for your offensive question?

Would be great if you could take the time to answer the questions below so I better understand your "concerns".

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 ...

Cheers cwsoft
Title: Re: Codesnippet: Anynews
Post by: Argos on September 03, 2012, 07:13:57 PM
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. But if it is merely a next version without many real changes I don't see a valid reason for a name change. It only creates confusion. But if you want to consolidate your work into a new name, and thus forking the module, you have of course that right.

I don't think you should take the "stupid" that serious. But you could explain the reason for the name change nevertheless.
Title: Re: Codesnippet: cwsoft-anynews
Post by: cwsoft on September 03, 2012, 08:19:13 PM
@Argos: Please check your inbox, I sent you a PM. First would like to wait for a possible answer to my questions raised before further commenting on that :wink:
Title: Re: Codesnippet: Anynews
Post by: Bug on September 04, 2012, 08:18:07 AM
// Just curious. Is there any special reason for your offensive question?

Take it back one step, was there any special reason in changing the module name...


//What exactly are the issues/concerns caused by the name change compared to any previous update for you or your clients?

If anyone that alters a module is going to add his name to the module name this whole cms is will become a big joke

// in which process of the installation/upgrade path get you or your clients confronted with the name change?

I think you are starting to see the pointlessness of the namechange

// 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 ...

Is this a new question or just the first question again to see if i will give the same answer?


Ps, i changed the core of wb a bit, shall i present a version called 'Website Bug' in stead of website baker?


Pps, just be reasonable and keep all stuff here simple and clear, for the most people here the stuff going on with the cms and modules is hard enough, the separation from our german untermembers still calls too much questions and if people will now start to rename modules because of some misplaced self-glorification i think we are heading the wrong way.
Title: Re: Codesnippet: cwsoft-anynews
Post by: Stefek on September 04, 2012, 02:24:13 PM
Bug, cwsoft already said why he has changed the name of his module(s).
And I don't like it how you treat developers here. Insted of answering his questions you just require to adjust to your needs and wishes. You should better honor the products people provide to the community for free instead of ruthlessly demanding an adjustment to your likes.
This is plain stupid. Sorry.
Title: Re: Codesnippet: cwsoft-anynews
Post by: Bug on September 04, 2012, 03:28:15 PM
You should better honor the products people provide to the community for free

I do,
but i just do not understand why thing sometimes are being presented in complicated ways..

Quote
And I don't like it how you treat developers here
I am not here to be nice, i am trying to be helpful
Title: Re: Codesnippet: cwsoft-anynews
Post by: Stefek on September 04, 2012, 03:32:29 PM
If you want to help, please try to answer the questions instead of re-questioning them.

Quote
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 ...

Title: Re: Codesnippet: cwsoft-anynews
Post by: Bug on September 04, 2012, 04:00:17 PM
If you want to help, please try to answer the questions instead of re-questioning them.


still don't get the point but here it goes


Q1: What exactly are the issues/concerns caused by the name change compared to any previous update for you or your clients?
- for me: nothing, i tend to rename modules to normal understandable names anyway
- for clients: they do not have access to and or knowledge about the anynewsmodule
- 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 variationss


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?
- for me: nothing, i tend to rename modules to normal understandable names anyway
- for clients: they do not have access to and or knowledge about the anynewsmodule
- 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

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 ...
- for me: nothing, i tend to rename modules to normal understandable names anyway
- for clients: they do not have access to and or knowledge about the anynewsmodule
- 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
Title: Re: Codesnippet: cwsoft-anynews
Post by: Argos on September 04, 2012, 05:53:43 PM
Quote from: cwsoft
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.

Quote from: Bug
- 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

These are the reasons I think name changes should be kept to a minimum, and I prefer to keep existing names, especially for long existing often used modules like this. Personally I think name changes can be functionial for forks, or old, 'sleeping' modules that are being revived and structurally updated.

To be honest, I would have preffered AnyNews to stay AnyNews, to prevent confusion, extra work and potential problems when upgrading. But on the other hand, he did a wonderful job modernizing and extending the old module, and so it is in fact a fork. So I can understand him wanting to rename the fork. But maybe it's an idea to give it a completely new name then, like for example ShowNews.

Just my two cents...
Title: Re: Codesnippet: cwsoft-anynews
Post by: Bug on September 04, 2012, 06:01:53 PM
i meant to say what argos said, ... maybe I am a bit more rough around the edges

meanwhile the new features look very nice

Title: Re: Codesnippet: cwsoft-anynews
Post by: cwsoft on September 04, 2012, 06:08:13 PM
Hi,

@Bug: Thanks for taking the time to answer my questions.
The questions I raised are the ones I asked myself before deciding to go for the module name changes. Reviewing your answers to my three questions, you basically came to the same conclusion. There is no direct consequence for users e.g. issues with backward incompatible changes etc., which would have been a no go for me.

What made me a bit "angry" was your offending way of asking for the reason of the name change instead of formulating your question in a more polite and neutral way (without words like stupid) as you demanded for yourself in one of your last posts quoted below. Similar to your answer, I do not change module names just for fun and without considering possible side effects for users and customers beforehand.

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.

What justifies the name change:
I took over responsibility for my modules Anynews, Addon-File-Editor and Postits in February this year, after maintenance by previous forum members has stagnated for about 1.5 years and "modified" module versions with adaptions for latest WebsiteBaker or jQuery versions, and/or backwards incompatible changes (e.g. Anynews versions with changed function parameters) were spread around via the forum.

As a consequence, I decided in Februar 2012, to "fork" my own modules at GitHub to give them a new home with a public repository for better code and feature request tracking and easier possibilities for contributions (via GitHub fork/pull mechanism etc.), instead of the very user unfriendly way of searching the forum for "patches" and "latest versions". With the first new releases, I increased the major module version number to the next higher integer number to make the "fork" and the new start of maintenance support "visible". At this point in time I thought increasing the major version number would be sufficient.

Quote from: argos
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.).

The list below gives a brief overview of the "new features" added since February:
 - updated jQuery file inclusion to work with newer WB versions
 - added new jQuery slider plugin: "Flexslider"
 - made jQuery Plugins customizable without touching external plugin files
 - moved all hardcoded Anynews output to template files
 - fixed broken sort by comments feature added by another forum member
 - added option to filter news not only by group but also by: page, section, and post id
 - added option to filter news by page language
 - introduced the much more flexible template parser Twig
 - updated all templates to Twig
 - reworked the entire README (https://github.com/cwsoft/wb-cwsoft-anynews#readme)

The name change is finally a result of all the work I put into the "forked module" since February 2012, plus some branding with my domain cwsoft.de, plus the fact that "outdated" Anynews versions (not supporting WB 2.8.x) are listed at AMASP (http://www.websitebakers.com/pages/code-snippets/listings/anynews.php) without having control of updating the content as my request for a new AMASP account was refused, while receiving funny PMs or E-mails at the same time asking me to update those outdated modules.
Apart from that, two Anynews versions are listed at the actual WB Module repository (http://www.websitebaker2.org/de/add-ons/module/code-snippets.php) - both with the same module name, but one for WB 2.7, the other for WB 2.8.x series only. All this is from my point of view sub-optimimal and adds confusion.

The sum of all that made me finally believe that a name change (including my branding cwsoft) is well justified. At the end it is the decision of the module author (which it's me) to choose an appropriate module name :wink:

Quote from: Argos
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:

Quote from: Bug
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
I 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).

At the time the new repository is available I would have asked for splitting the Postits (https://forum.WebsiteBaker.org/index.php/topic,4548.msg157963.html#msg157963) and Anynews (https://forum.WebsiteBaker.org/index.php/topic,12122.msg157950.html#msg157950) threads at my initial GitHub announcement post and to create seperate threads with the new name "cwsoft-module-name" :wink:

My final words on this topic.

Cheers
Title: Re: Codesnippet: cwsoft-anynews
Post by: Bug on September 04, 2012, 07:54:25 PM
Good to read the whole story,

Nice to see people making stuff better,

I myself am at 90% of loading al sorts of extra's into a newsmodule, i will send you a versiosn asap, maybe you will find some inspiration to expand the anynews with some of those fields,

For instance i am adding a flexible anchorlinktext so that each item can have a 'read more about this and that' link in stead of all having 'read more', i have added two fields, one for the normal link from the page to the long item, one for the anynews,
I also added an extra short message field so that the anynewsmessage can differ from the normal short, i changed ( the old) anynews to be able to work with either {SHORT} or { SHORT2},

it would be great to see news, anynews, bakery and wysiwyg evolve a bit
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on September 09, 2012, 10:01:36 AM
@all: I finally renamed this thread into: "Snippet: cwsoft-anynews" and added all background information and details to the very first post (https://forum.WebsiteBaker.org/index.php/topic,23355.msg157948.html#msg157948) in this thread.

Cheers
Title: Re: Snippet: cwsoft-anynews
Post by: ruebenwurzel on October 25, 2012, 10:51:29 AM
Hello,

have a small problem with the paramater "allowed tags". I use the following call:

Code: [Select]
<?php
displayNewsItems
(1,5,-1,5,'AUTO',true,'<a><br />')
?>

The template is:

Code: [Select]
{% for news in newsItems %}
<a href="{{ news.LINK }}"><strong>{{ news.TITLE }}</strong></a><br />
{{ news.CONTENT_SHORT}}<br /><br />
{% endfor %}

The short content is:

Code: [Select]
<p>Sa. 15.12.2012, 16.00 Uhr<br />
Amtshauskeller Frdbg.<br />
Eintritt frei</p>

So I expect in the source code:
Code: [Select]
Sa. 15.12.2012, 16.00 Uhr<br />
Amtshauskeller Frdbg.<br />
Eintritt frei

But the result is:
Code: [Select]
Sa. 15.12.2012, 16.00 Uhr
Amtshauskeller Frdbg.
Eintritt frei

So it seems that the "<br />" Tag is striped althought it is allowed.

Matthias
Title: Re: Snippet: cwsoft-anynews
Post by: marmot on October 25, 2012, 06:50:02 PM
Hi,

So it seems that the "<br />" Tag is striped althought it is allowed.
just allow the "normal form" of the tag:
Code: [Select]
displayNewsItems(1,5,-1,5,'AUTO',true,'<a><br>')
regards
Title: Re: Snippet: cwsoft-anynews
Post by: ruebenwurzel on October 25, 2012, 08:07:46 PM
Woow,

that was easy. Sometimes one thinks to complicated.

Thanks marmot, it works like a charm.

Matthias
Title: Re: Snippet: cwsoft-anynews
Post by: badknight on October 25, 2012, 09:42:46 PM
Woow,

that was easy. Sometimes one thinks to complicated.

Thanks marmot, it works like a charm.

Matthias

read the documentation from "strip_tags" strip_tags (http://www.php.net/manual/en/function.strip-tags.php)
Quote
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.



Title: Changes at GitHub
Post by: cwsoft on December 17, 2012, 08:00:29 PM
For your information.

GitHub recently dropped support for managed downloads (https://github.com/blog/1302-goodbye-uploads). Up to now I offered WebsiteBaker ready installation packages of my modules via the Repository downloads sections, which is no longer available.

It is still possible to download an archive of the latest master branch using GitHubs "ZIP button" or download older "taged" module versions via GitHub Tags section (https://github.com/cwsoft/wb-cwsoft-anynews/tags). However those archives are dynamically created by GitHub including the repository folder itself, leading to invalid "WebsiteBaker installation zip files".

As workaround, just download the latest module version from the WebsiteBaker Add-on page (http://addons.websitebaker2.org/pages/en/browse-add-ons.php), or download the GitHub archive, unzip it locally and rezip it without the parent folder to make it a installable WebsiteBaker archive yourself.

Cheers
Title: Re: Snippet: cwsoft-anynews
Post by: firefoxfx on January 27, 2013, 08:14:17 PM
First off all thank for the hard work, i love this module.

I'm building a new mulitlanguage website with wb 2.8.3 rev 1638 and anynews 2.6.0 and the problem that i have is when i post a news item it shows up in anynews but only for that day. So when i'm posting a news item on 27-01-2013 and i check it back at 28-01-2013 it displays that there is no news available yet. I hope someone can help me because its driving me nuts.

Here is my template index config:

Code: [Select]
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'
   );

Anynews template config:

Code: [Select]
<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>

Thanks for the help
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on January 27, 2013, 08:30:18 PM
@firefoxfx

Your function parameter order seems weird. Can you please update your Anynews function parameter to match order and parameters shown in the Anynews README (https://github.com/cwsoft/wb-cwsoft-anynews#anynews-parametes).

PHP is not Python and you need take care about order and number of parameters passed by. Guess your call mixes up "not_older_than" (third last parameter) with "sort_by = 1", hiding news older than 1 day.

Just a guess, so give it try.

Cheers cwsoft

Title: Re: Snippet: cwsoft-anynews
Post by: firefoxfx on January 27, 2013, 08:43:19 PM
thanks cwsoft, i copied the order from the read me and that did the trick.
Title: Re: Snippet: cwsoft-anynews
Post by: dana on February 04, 2013, 12:17:03 PM
Here is a Czech translation:
Code: [Select]
<?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'
);
Title: Re: Snippet: cwsoft-anynews
Post by: dana on February 04, 2013, 12:42:50 PM
Also, for some reason the $max_news_length is not working for me. I have this in my template:
Quote
<?php
        if (function_exists('displayNewsItems')) {
          displayNewsItems(
            $group_id = 0,
            $max_news_items = 3,
            $max_news_length = 40,
            $display_mode = 2,
            $lang_id = 'AUTO'
          ) ;
        }
      ?>

But this displays the whole short story. When I set it to 10, it displays '...'. Any help is appreciated! :)
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on February 04, 2013, 06:49:13 PM
Hi,

Quote from: dana
Here is a Czech translation
Great, 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:

Quote from: dana
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.

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
Title: Re: Snippet: cwsoft-anynews
Post by: dana on February 06, 2013, 11:36:59 AM
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

I probably should have posted also my display_mode = 2 template, as I have edited it to suit my needs. :)

Code: [Select]
<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>

When I set display_mode to 1, the entire short news is posted, regardless of the length. $strip_tags = false did not help either. :(
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on February 06, 2013, 07:32:08 PM
@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..."

If I find some free time, I will have a look and maybe rework the truncate function or use the simple plain text filters provided by the Twig template lib.

If you need this feature urgent, try the following workaround:
 a) set $max_news_length = -1 (to switch off truncating by Anynews)
 b) do the truncation in your customized Anynews template (adapt slice(0,20) and line below to your needs)

Code: [Select]
<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>

Cheers
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on February 07, 2013, 09:36:31 PM
@dana: I replaced the Anynews truncate function with the latest available PHPCake version available and pushed it to GitHub (https://github.com/cwsoft/wb-cwsoft-anynews). Maybe you want to give it a try.

Bear in mind that the GitHub ZIP archive needs to be unzipped and zipped without any parent folder to work with WebsiteBaker installer. For details see README at GitHub. If you install the new version, remember to backup your customized templates first, otherwise they will be overwritten.

Cheers
Title: Re: Snippet: cwsoft-anynews
Post by: owk444 on February 08, 2013, 09:05:23 AM
Here is Russian translation.

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. :-(
Title: Re: Snippet: cwsoft-anynews
Post by: dana on February 08, 2013, 01:50:08 PM
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. :-(

I don't think I quite understand your question. You can add another section to your website so there can be both wysiwyg and code sections.

@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. I have used the Lorem droplet for the news for testing purposes. So when I add a plain text, it works okay. :)

Title: Re: Snippet: cwsoft-anynews
Post by: owk444 on February 08, 2013, 02:52:33 PM
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.
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on February 08, 2013, 04:24:10 PM
Hi,

Quote from: dana
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.

Quote from: owk444
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.

Quote from: owk444
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.

As Anynews outputs the processed template directly to the screen, one would need a small change in the Anynews code to serve Anynews output as Droplet. Will most likely add a Anynews Droplet with the next Anynews release to achieve the same without "messing" with the WebsiteBaker output buffer system :wink:

Meanwhile you may want to test this quick & dirty solution (most likely conflicts with other droplets on same page):

 1. go to WebsiteBaker backend / Admin-Tools / Droplets
 2. press the "Add Droplet" button
 3. enter the droplet name displayNewsItems and a description
 4. enter the following code to the Droplet and save the result
 5. invoke [[displayNewsItems]] from your WYSIWYG section

Anynews droplet code (quick & dirty):
Code: [Select]
// 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;

Cheers
Title: Re: Snippet: cwsoft-anynews
Post by: owk444 on February 08, 2013, 08:06:54 PM
Thank you for droplet code! It works fine!

Description in the file translated. File attached.
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on February 08, 2013, 08:44:35 PM
@owk444: Thanks for the Russian langauge file. Uploaded it to GitHub repository (https://github.com/cwsoft/wb-cwsoft-anynews), so it will be issued with the next release.

Cheers
Title: cwsoft-anynews 2.8.0 RELEASED
Post by: cwsoft on February 10, 2013, 10:05:49 AM
Hello,

cwsoft-anynews v2.8.0 stable is available at GitHub (https://github.com/cwsoft/wb-cwsoft-anynews) and the WebsiteBaker Add-ons repository (http://addons.websitebaker2.org/pages/en/browse-add-ons.php?id=0C80D11).

Updates since last release:
- added Czech and Russian language file (thanks to forum members dana and owk444)
- updated truncate function to latest available version (thanks to dana for the hint)
- implemented more flexible parameter handling via new function getNewsItems()
- added option to invoke cwsoft-anynews via a custom Droplet (requested by owk444)

Since Version 2.8.0 the new function getNewsItems() is included, providing a more flexible configuration via a configuration array. This allows you to specifiy ONLY the parameters you want to change, without taking care of position and order of other possible parameters. To ensure backward compatibility, the function displayNewsItems() will work as before, but was marked "deprecated" in favour of the new and more flexible getNewsItems() function. It's recommended to use the latter function for all your new projects. See README (https://github.com/cwsoft/wb-cwsoft-anynews#readme) for details.

Anynews Droplet:
Since Anynews v2.8.0 droplet code is included, allowing you to create your own Anynews Droplet usable in WYSIWYG editor or your template by pasting the following three code lines into the Droplet code form.
Code: [Select]
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;

The Anynews Droplet supports all Anynews parameters (except the rarely used parameter 'custom_placeholder'). For details about the Droplet function see documentation at GitHub (https://github.com/cwsoft/wb-cwsoft-anynews#use-anynews-from-a-droplet).

Cheers cwsoft
Title: Re: Snippet: cwsoft-anynews
Post by: dimlaz on February 10, 2013, 12:04:37 PM
Hello,

Can please someone help since I am a beginner here.

I have two pages that contain news posts, the one of these news posts are the Latest news, which I want to display the titles and a short description on my homepage.

iI use the following code:
<?php
                   $config = array(
                   'section_id' => 8,
                   'sort_order' => 2,
                   'display_mode' => 2,   
                     );
                     echo getNewsItems($config);
                      ?>
The result is that it displayes the news from both news categories, it wont display only the Latest News category, it seems that the section_id, group_id does not work.

Can someone please help.

Thanks
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on February 10, 2013, 12:24:30 PM
Hi,

Quote from: dimlaz
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.

If you want to limit Anynews output to a given section, you need adapt yor config array as follows:

Code: [Select]
$config = array(
  'group_id' => 8,
  'group_id_type' => 'section_id',
);

Details about the supported Anynews parameters (https://github.com/cwsoft/wb-cwsoft-anynews#customize) are given at GitHub.

Cheers

P.S.: Nice to see people already start using the new syntax :wink:
Title: Re: Snippet: cwsoft-anynews
Post by: dimlaz on February 10, 2013, 12:34:29 PM
 :-)
Great,

Thanks for the help, it works now.

Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on February 10, 2013, 12:58:18 PM
Hi,

Quote from: dimlaz
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.

To achieve what you want with the old displayNewsItems function, one would have needed to provide ALL parameters in right order, even though one needs to change only the first ($group_id) and last parameter ($group_id_type). Sometimes I wish PHP would be more similar to Python.

Cheers
Title: Re: Snippet: cwsoft-anynews
Post by: StephanLE on February 10, 2013, 05:04:59 PM
Can one code section also pass parameters?
Code: [Select]
if (function_exists('getNewsItems')) {
    echo getNewsItems();
}
If so how?
I do not get it out the embed.
Code: [Select]
$max_news_length = 30,
$display_mode = 3,
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on February 10, 2013, 05:25:25 PM
Hi,

Quote from: StephanLE
Can one code section also pass parameters?
Note quite sure I really understand what you are after, but lets try.

Option 1: requires cwsoft-anynews >= v2.8.0
Code: [Select]
if (function_exists('getNewsItems')) {
    echo getNewsItems(array(
     'max_news_length' => 30,
     'display_mode' => 3,
    ));
}

Option 2: requires cwsoft-anynews >= v2.8.0
Code: [Select]
if (function_exists('getNewsItems')) {
   $options = array(
     'max_news_length' => 30,
     'display_mode' => 3,
   );
  
    echo getNewsItems($options);
}

The old $parameter = VALUE (displayNewsItems) just translates into 'parameter' => VALUE (getNewsItems).

Tip:You could also create a Droplet and use [[getNewsItems?parameter1=VALUE&parameter2=VALUE2]] in a WYSIWYG section or your template, following the steps explained in the README (https://github.com/cwsoft/wb-cwsoft-anynews#use-anynews-from-a-droplet).

Cheers
Title: Re: Snippet: cwsoft-anynews
Post by: StephanLE on February 10, 2013, 07:22:23 PM
Thank you

You heard me all right.
I chose option 2. It now works as it should.
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on February 10, 2013, 07:27:25 PM
Hi,

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.

Cheers
Title: cwsoft-anynews v2.8.2 RELEASED
Post by: cwsoft on February 12, 2013, 06:45:31 PM
Hello,

cwsoft-anynews v2.8.2 stable is available at GitHub (https://github.com/cwsoft/wb-cwsoft-anynews) and the WebsiteBaker Add-ons repository (http://addons.websitebaker2.org/pages/en/browse-add-ons.php?id=0C80D11).

Updates since last release:
- fixed regression with multiple Anynews Droplet calls at one page/section
- fixed two possible PHP notices/warnings

cwsoft
Title: Re: Snippet: cwsoft-anynews
Post by: Argos on May 10, 2013, 03:03:21 PM
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.

Quote
[[getNewsItems?group_id=27&max_news_items=5&max_news_length=80&display_mode=50&not_older_than=360&group_id_type='section_id']]

And this (use page ID 9) doesn't work either:
Quote
[[getNewsItems?group_id=9&max_news_items=5&max_news_length=80&display_mode=50&not_older_than=360&group_id_type='page_id']]

And also the regular code calls don't seem to work with page_id and section_id...
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on May 10, 2013, 06:56:12 PM
Hi Argos,

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.

Code: [Select]
[[getNewsItems?group_id=27&group_id_type='section_id']]
Anynews droplet parameters needs to be passed over without quotes (see section_id):
Code: [Select]
[[getNewsItems?group_id=27&group_id_type=section_id]]
Quote from: argos
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.

If you can't get it working, try it first without the other parameters (just group_id and group_id_type) and double check group_id are right. Hope this helps.

Cheers

P.S.: next version (https://github.com/cwsoft/wb-cwsoft-anynews/commit/4b893dc6729cb41f4e0a4b0e62595825bdfaee54) will manage unquoted and quoted droplet parameters to remove this possible error source :wink:
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on May 12, 2013, 08:24:18 AM
@argos: Did removing the quotes around the cwsoft-anynews droplet parameter solve your issues with the droplet call?
If not what cwsoft-anynews version and WB version are you using?
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on May 17, 2013, 05:09:52 AM
@argos: Guess no news/feedback are good news and your issues are solved with the infos given two posts before. In other words I assume the reported issue is fixed.
Title: Re: Snippet: cwsoft-anynews
Post by: Argos on May 17, 2013, 12:00:58 PM
Wrong assumption. I just didn't have the time to test yet. Especially because I uninstalled the latest version and went back to a previous one that I knew worked fine. Had to continue with this client site. But I will try and test the latest version on my test site asap.
Title: Re: Snippet: cwsoft-anynews
Post by: Argos on June 05, 2013, 12:34:54 PM
Is it possible to bypass the default date format set in the Admin Settings, just for the AnyNews function?

I'd like to add classes to the date elements and style the date output, so I can create date "icons" like you see for example on http://code.garyjones.co.uk/style-post-info?
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on June 05, 2013, 12:56:09 PM
@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.

Cheers
Title: Re: Snippet: cwsoft-anynews
Post by: Argos on June 05, 2013, 05:45:13 PM
@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.

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?

This is my code:

Code: [Select]
{% 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 %}

And I added these classes:
Code: [Select]
.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;}

This looks like the schreenshot. While the abreviation for June is "Jun" in both English and Dutch, I tested it with "F" instead of "M", and it shows the English "June" instead of the Dutch "Juni".
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on June 05, 2013, 06:55:17 PM
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.

Another option is to create an array in the Twig template holding the Dutch month names from Jan to Dec and use date function to return the month as integer value 1-12 as index for the array. For details see the excellent Twig online help (http://twig.sensiolabs.org/doc/templates.html).

Cheers
Title: Re: Snippet: cwsoft-anynews
Post by: Argos on June 05, 2013, 11:27:33 PM
Way over my head...  :cry:

Doesn't this Twig stuff just add a big layer of complexity to this snippet?
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on June 06, 2013, 07:08:59 AM
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.

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.

Creating an array with month names is a just one code line in Twig shown in the documentation I linked before , so I don't see the big complexity :wink:

Cheers

P.S.: guess you had no time yet to check the modifications I applied based on your request some weeks ago - or :-)
Title: Re: Snippet: cwsoft-anynews
Post by: Argos on June 06, 2013, 11:56:51 AM
I'm sure Twig is great for coders, but I'm not a coder  :|

With my limited PHP skills I can tweak WB code a bit sometimes, and with lots of trial & error and lots of help from others I sometimes succeed. But in fact I often don't have clue what code does, and I cannot create code myself. So for me Twig just adds another layer of mumbo jumbo LOL. Don't take it personally, your work to modernize and maintain the modules and snippets is much appreciated!

So what a simple line of code is for you, is an impossibility for me :cry:

But if you help me out here, I can finish the client site today or tomorrow, and I promise after that I'll check out the things we discussed before. So this week. Deal?  :roll:
Title: Re: Snippet: cwsoft-anynews
Post by: marmot on June 07, 2013, 11:38:05 PM
Hi,

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:
Code: [Select]
find fixed code below
regards
Title: Re: Snippet: cwsoft-anynews
Post by: Argos on June 08, 2013, 01:31:10 AM
Thanks marmot. It doesn't work however.
Title: Re: Snippet: cwsoft-anynews
Post by: marmot on June 08, 2013, 08:52:45 PM
Hi,
Thanks marmot. It doesn't work however.
now it does (just a missing "[" in line 1:
Code: [Select]
{% 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 %}

regards
Title: Re: Snippet: cwsoft-anynews
Post by: Argos on June 10, 2013, 01:04:31 PM
Thanks, but doesn't work. There is no output for the month, only the day.
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on June 10, 2013, 05:56:01 PM
@marmot: Your code example will work after two small updates:

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

Changes in template:
Code: [Select]
<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>

Changes in include.php
Remove the date conversion (https://github.com/cwsoft/wb-cwsoft-anynews/blob/master/cwsoft-anynews/include.php#L250-L252) from the inlcude.php to look as follows:

Code: [Select]
'POSTED_WHEN'     => $row['posted_when'],
'PUBLISHED_WHEN'  => $row['published_when'],
'PUBLISHED_UNTIL' => $row['published_until'],
'DATE_FORMAT'     => $LANG['ANYNEWS'][0]['DATE_FORMAT'],

Will most likely change this with a future release. Either by adding new fields like POSTED_WHEN_TS (timestamp) and extra field DATE_FORMAT to ensure backward compatibility with customized templates.

Cheers
Title: Re: Snippet: cwsoft-anynews
Post by: marmot on June 10, 2013, 06:37:01 PM
Hi,

1. month index needs to be reduced by 1 as date("m") starts with 1 but Twig arrays starts with 0
ok I missed that completely.
Quote
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.

Quote
this needs to be removed from include.php to allow conversion of the numeric TIMESTAMP in Twig using the date modifier
vs
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:

regards
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on June 10, 2013, 06:56:29 PM
Hi,

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  shocked, although it was not really clever to code like that.
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.

I sometimes wish PHP would behave more like Python in some aspects:
Quote from: ZEN of python (http://www.python.org/dev/peps/pep-0020)
Errors should never pass silently. Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.

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:
Sure, Twig still rocks.

Date conversion should be part of the view (template) and not of the model (include.php). So this has nothing to do with Twig, it's just an example of a bad design decission I made some years ago (v0.32 Jan 04 2009 to be precise), which I will fix with the next release (https://github.com/cwsoft/wb-cwsoft-anynews/commit/528d1c4d86c770ea6fa12f4e275be76c63669e8c) :wink:

Cheers
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on June 11, 2013, 10:50:24 PM
Hi,

added the new Twig filter strftime which allows timestamp conversion via PHP strftime function to the cwsoft-anynews master branch (https://github.com/cwsoft/wb-cwsoft-anynews#download).

Twig strftime filter:
{{ timestamp | strftime('format_string', ['array','with','supported','locals']) }}

Infos: PHP strftime (http://php.net/manual/en/function.strftime.php), PHP setlocale (http://php.net/manual/de/function.setlocale.php)

Example usage in template:
Code: [Select]
<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>

Parsed Anynews output:

P.S.: To convert first chars in the Dutch date to upper case, pipe the output of the strftime filter through the Twig title filter (http://twig.sensiolabs.org/doc/filters/index.html):
Code: [Select]
{{ news.TS_POSTED_WHEN | strftime('%A, %B %Y', ['nl_NL', 'dutch']) | title }}

Cheers
Title: Re: Snippet: cwsoft-anynews
Post by: Argos on June 14, 2013, 12:48:22 PM
Thanks cwsoft, that works fine!  :-D
Title: Re: Snippet: cwsoft-anynews
Post by: Argos on June 14, 2013, 03:15:09 PM
@argos: Did removing the quotes around the cwsoft-anynews droplet parameter solve your issues with the droplet call?

Yep, everything works fine and as expected. I use your latest version now by the way, with the locale addition.
Title: cwsoft-anynews v2.9.0
Post by: cwsoft on June 18, 2013, 08:18:40 PM
Hello,

cwsoft-anynews v2.9.0 stable is available at GitHub (https://github.com/cwsoft/wb-cwsoft-anynews) and the WebsiteBaker Add-ons repository (http://addons.websitebaker2.org/pages/en/browse-add-ons.php?id=0C80D11).

Updates since last release:
- updated droplet to accept quotes around parameters (thanks to Argos for reporting)
- added timestamp placeholders for more flexible date/time conversion in template
- added Twig filter strftime for easy date/time format using locale settings (e.g. Friday, 6 May 2013)
- updated 3rd party packages to latest available version
- removed deprecated function hints from README

cwsoft
Title: Re: Snippet: cwsoft-anynews
Post by: Argos on June 19, 2013, 12:01:15 AM
Thanks for your work!  :-)
Title: Re: Snippet: cwsoft-anynews
Post by: xoanon on June 19, 2013, 06:44:37 AM
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  );
}

Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on June 19, 2013, 08:15:51 AM
@xoanon: Please provide the requested information about your system and post the Anynews function call. Otherwise we can just guess whats going on here.

Infos needed: https://github.com/cwsoft/wb-cwsoft-anynews#questions

Cheers
Title: Re: Snippet: cwsoft-anynews
Post by: Ruud on June 19, 2013, 10:15:49 AM
Same thing happeed to me..
Just installed Anynews on a (almost) clean website, and the website stopped with the same error.
There was no call to the snippet yet!
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on June 19, 2013, 10:55:59 AM
@Ruud: Same here. At least WB + PHP version is needed to help out. Tested this morning locally on XAMPP with PHP 5.4 and WB 2.8.3 SPx and had no issues at all.

Cheers
Title: Re: Snippet: cwsoft-anynews
Post by: Ruud on June 19, 2013, 11:15:59 AM
Tested on (wamp) PHP 5.2.6 with WB 2.8.3 SP1 (1638)

Code: [Select]
Parse error: syntax error, unexpected T_FUNCTION in {removed}\wb\modules\cwsoft-anynews\include.php on line 107
Title: Re: Snippet: cwsoft-anynews
Post by: xoanon on June 19, 2013, 04:42:38 PM
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  );
}



the additional info requested is:

========================================
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  );
}
>>>>   fixed the problem with the "anynews" clickable-description-links...  <<<
The module "minislider" displayed just above "anynews" is a bit of a strange case... it does not really control the height of the images it displays correctly (via a .js file). So I had to insert a <style> statement in the template to restrict the height rather than allow "minislider" to think that the whole page/section is under its control... so by including the following l-style-lines- the problem is solved

#slider {
    height: 440px;
    overflow: hidden;
}

However the original problem is still there if I remove the comment from this line....
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...

LINE 107:    $twig->addFilter(new Twig_SimpleFilter('strftime', function ($timestamp, $format, $locales) {
setlocale(LC_ALL, $locales);
return strftime($format, $timestamp);
}));
Title: Re: Snippet: cwsoft-anynews
Post by: Ruud on June 20, 2013, 01:56:46 PM
Tested on (wamp) PHP 5.2.6 with WB 2.8.3 SP1 (1638)

Just tested on a live server with PHP 5.4.16 (same WB).
Works without problems there.
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on June 20, 2013, 06:32:04 PM
@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.
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on June 20, 2013, 08:53:22 PM
@xoanon: I recommend to upgrade to the more flexible getNewsItems function introduced with cwsoft-anynews 2.8.0. The function getNewsItems allows you to configure only the parameters you want to change, making it more easy to read. Your code example would translate into (default parameters omitted):

Code: [Select]
if (function_exists('getNewsItems')) {
$options = array(
'max_news_items' => 4,
'display_mode' => 2,
);

echo getNewsItems($options);
}

Details about the default parameters can be found at GitHub (https://github.com/cwsoft/wb-cwsoft-anynews#anynews-configuration).

Cheers
Title: Re: Snippet: cwsoft-anynews
Post by: xoanon on June 21, 2013, 03:21:06 AM
thanks
already changed to the new function  "getNewsItems"
Title: Re: Snippet: cwsoft-anynews
Post by: xoanon on June 21, 2013, 03:24:43 AM
@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.

Hi
can I just replace the "include.php" file or need the whole package?
?
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on June 21, 2013, 06:09:05 AM
@xoanon: I changed two files:: "include.php" and "code/anynews_function.php":
https://github.com/cwsoft/wb-cwsoft-anynews/commit/8fd7175324facb2d16c65da08c93865ae8df9c0c

Cheers
Title: Re: Snippet: cwsoft-anynews
Post by: xoanon on June 21, 2013, 12:42:49 PM
ok, thanks,  looks ok for display mode 1,2,3,4
but I tried display=6
with the following
a) HTML section:
Code: [Select]
[[getNewsItems?display_mode=2]]

b) CODE2 section:
Code: [Select]
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,
    ));
}

c) display_mode_6.htt    (from an earlier post)
Code: [Select]
<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 %}

and get the following errors
>>>>>
Code: [Select]
[[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)
>>>>>.
Am I doing something wrong?

//edit by Badknight:
please use the [code] tag - thanks
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on June 21, 2013, 09:21:04 PM
Hi,

if you pass over all default values to the getNewsItems function anyway, you can also stick to the old function :wink:

display_mode = 6 does not work due to an error in your template. The error was already discussed and a solution was provided in this thread. Instead of blind copy and paste of forum code, maybe first try to read through the last posts  :wink:

Hint: the date filter works best with timestamps (TS_PUBLISHED_WHEN). Just look how this is done in the default templates (https://github.com/cwsoft/wb-cwsoft-anynews/blob/master/cwsoft-anynews/templates/display_mode_1.htt#L32). A list of all variables is shown with display_mode = 99. This and more infos can also be found in the README at GitHub: https://github.com/cwsoft/wb-cwsoft-anynews#readme

Cheers
Title: cwsoft-anynews v2.9.1 available
Post by: cwsoft on June 24, 2013, 07:49:11 PM
Hello,

cwsoft-anynews v2.9.1 stable is available at GitHub (https://github.com/cwsoft/wb-cwsoft-anynews) and the WebsiteBaker Add-ons repository (http://addons.websitebaker2.org/pages/en/browse-add-ons.php?id=0C80D11).

Updates since last release:
- fixed a regression introduced with v2.9.0 affecting the outdated PHP 5.2.x series

cwsoft
Title: Re: Snippet: cwsoft-anynews
Post by: svsanchez on July 02, 2013, 01:58:13 AM
Hello Guys, thank you for this module however I am running into an already mentioned problem and I just can't figure it out, I already read the whole old 'anynews' thread and this one and I don't understand where is my error. I am building a site in 3 languages (EN, ES and RU) and anynews outputs the latest news mixed instead of showing only the EN news when I am in the English version or only the ES news when I am in the Spanish version.

I have the correct structure with en, es and ru folders as parents for their respective versions.

I created a news page under each en, es and ru and posted the news specifically for each language.

I also tried specifying the section_id and the language_filter without luck.

I had installed the Anynews V2.2 and then noticed the cwsoft-Anynews and installed the latest version (2.9.1) but I still have the same mixing of news in different languages problem.

This is how I am calling the news on my template:

<?php displayNewsItems(
/*   $section_id= 26, */
   $group_id = 0,
   $max_news_items = 3,
   $max_news_lenght = 50,
   $display_mode = 2,
   $lang_id = 'AUTO',
   $lang_filter = 'EN',
   $strip_tags = true,
   $allowed_tags = '<p><a><img>',
   $custom_placeholder = false,
   $sort_by = 1,
   $sort_order = 1,
   $not_older_than = 0
   );
?>

What am I doing wrong?
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on July 02, 2013, 07:51:22 AM
Hi,

multilingual output with anynews is a bit tricky, but doable.

First I would switch to the more easy configuration options using getNewsItems shown in the README. The old displayNewsItems function needs to have all parameters in the right order, which is not the case in your example. If you want stick to the old function, follow the instructions for Anynews <2.8 linked in the README (https://github.com/cwsoft/wb-cwsoft-anynews#readme) (section configuration).

Create one news page with the WB news module for each language you have or create one group for each language. Then call Anynews for each language using  set lang_id = 'LANG' and the group or sectionID for the individual language.

Another option is to organize your URL to include the language flage (e.g. mydomain/EN/news.php). In this case you can try the Anynews flag lang_filter = true and lang_id = 'AUTO' combination to let Anynews choose the language file depending on the URL language fragment.

Cheers
Title: Re: Snippet: cwsoft-anynews
Post by: svsanchez on July 02, 2013, 08:50:16 AM
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!
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on July 03, 2013, 07:10:56 AM
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.

I highly recommend to use getNewsItems over the old and deprecated displayNewsItems due to the more flexible and less error prone configuration. The old displayNewsItems call became more and more clumbsy with each new feature, while maintaining backward compatibility at the same time :|

A function or method with more than 3-4 Parameters is a strong sign for the need of some refactoring. First Anynews code from fienieg (http://www.WebsiteBaker.org/forum/index.php/topic,409.msg2186.html#msg2186) had no parameters and needed to be manually copied into a code section or template index.php file. My initial Anynews Code Snippet module has grown from from 6 (http://www.WebsiteBaker.org/forum/index.php/topic,409.msg34661.html#msg34661) to 13 optional configuration options over it's entire life cycle :wink:

Cheers
Title: Re: Snippet: cwsoft-anynews
Post by: daydreamer on July 03, 2013, 11:57:25 AM
Do you have a download link for getNewsItems?
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on July 03, 2013, 12:06:13 PM
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:
Title: Re: Snippet: cwsoft-anynews
Post by: daydreamer on July 03, 2013, 02:06:28 PM
Thanks  :-)

Is this call right?

Code: [Select]
<?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,
);
}
?>
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on July 03, 2013, 03:46:26 PM
Hi,

Quote from: daydreamer
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.

Just have a look at the code shown in the section Example of the README (https://github.com/cwsoft/wb-cwsoft-anynews#anynews-configuration). Remember that you only need to define the parameters in the config array you want to change.

Cheers
Title: Re: Snippet: cwsoft-anynews
Post by: daydreamer on July 03, 2013, 08:37:54 PM
Ok, I'm not really up with php so not sure how to add in my template to show display mode 3. Could you show me how I can do this please?

Thanks
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on July 03, 2013, 09:20:50 PM
Hi,

have you tried the code shown in the Example section (https://github.com/cwsoft/wb-cwsoft-anynews#anynews-configuration) of the README I linked in my last post? It provides the code needed to render news with a user specified template.

This code is posted in the README example sections:
Code: [Select]
// customized cwsoft-anynews function call
$config = array(
    'group_id' => 8,
    'group_id_type' => 'section_id',
    'display_mode' => 4,
);
echo getNewsItems($config);

and this would be a custom version which just sets display_mode to 3 and keeps all other defaults unchanged.
Code: [Select]
$config = array(
    'display_mode' => 3,
);
echo getNewsItems($config);


Cheers
Title: Re: Snippet: cwsoft-anynews
Post by: daydreamer on July 04, 2013, 11:26:37 AM
Thanks for that should read more clearly my bad
Title: Re: Snippet: cwsoft-anynews
Post by: fordfairlane on July 19, 2013, 11:16:01 AM
Here's the Danish language file:

Code: [Select]
<?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'
);
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on July 19, 2013, 05:56:31 PM
Here's the Danish language file
Great - 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.

Regards cwsoft
Title: cwsoft-anynews v2.10.0 available
Post by: cwsoft on July 21, 2013, 11:11:52 PM
Hello,

cwsoft-anynews v2.10.0 stable is available at GitHub (https://github.com/cwsoft/wb-cwsoft-anynews) and the WebsiteBaker Add-ons repository (http://addons.websitebaker2.org/pages/en/browse-add-ons.php?id=0C80D11).

Updates since last release:
- set minimum PHP version to 5.2.4 (Twig requirement)
- added Danish language file from user fordfairlane (thanks)

cwsoft

P.S.: Also big thanks to Ruud for keeping the WebsiteBaker Add-on repository in sync with my releases - highly appreciated
Title: cwsoft-anynews v2.11.0 released
Post by: cwsoft on March 03, 2014, 05:54:15 PM
Hello,

cwsoft-anynews v2.11.0 stable is available at GitHub (https://github.com/cwsoft/wb-cwsoft-anynews) and the WebsiteBaker Add-ons repository (http://addon.WebsiteBaker.org/pages/en/browse-add-ons.php?id=0C80D11).

Updates since last release:
- news created by the WB news module but not yet saved are not displayed by Anynews by default
  Thanks to samir2000 and jacobbi22 for bug reporting and analysis. As pointed out by jacobi22, the correct fix is to
  set "Active=0" in the WB-News module when a news post is created and update to 1 when saved the first time.
- updated 3rd party packages

Announcement:
Most likely I will remove the outdated and no longer maintained 3rd party jQuery "better-coda-slider" with the next cwsoft-anynews release. Shouldn't be a big issue, as it seems this slider isn't used that often and you can easily switch to the jQuery flexslider also shipped with Anynews :wink:

cwsoft

P.S.: Thanks to Ruud for updating the WebsiteBaker Add-on repository with the latest version
Title: cwsoft-anynews Template change
Post by: Roych on April 09, 2014, 10:25:28 PM
Hello

Im maybe stupid or crazy  :-P

But I can't figure out how to change the templates or any other functions! In which files?
I read the https://github.com/cwsoft/wb-cwsoft-anynews#readme (https://github.com/cwsoft/wb-cwsoft-anynews#readme)

But still dont understand where do I find those files ...

I want to have some other template and need only 3 news to show up.

Thank you wery much!
Title: Re: Snippet: cwsoft-anynews
Post by: Roych on April 09, 2014, 10:30:18 PM
Ok, never mind I found it! LOOOL!!!
Title: cwsoft-anynews v2.12.0 released
Post by: cwsoft on May 16, 2014, 07:21:42 AM
Hello,

cwsoft-anynews v2.12.0 stable is available at GitHub (https://github.com/cwsoft/wb-cwsoft-anynews) and the WebsiteBaker Add-ons repository (http://addon.WebsiteBaker.org/pages/en/browse-add-ons.php?id=0C80D11).

Updates since last release:
- added TIMEZONE to all Anynews time placeholders (thanks to samir2000 for reporting)
- added option to define the starting news item (thanks to jacobi22 for the suggestion)

The last item allows you e.g. to display the x-th to n-th news items by defining start_news_item and max_news_items. Using negative indizes for start_news_item will start from the x-th last news, allowing you also to display the last X news items more easily.

For details see README at GitHub (https://github.com/cwsoft/wb-cwsoft-anynews#anynews-configuration).

cwsoft

P.S.: Thanks to Ruud for updating the WebsiteBaker Add-on repository with the latest version
Title: Re: Snippet: cwsoft-anynews
Post by: daydreamer on June 02, 2014, 08:22:21 PM
Thanks for the updates :D
Title: cwsoft-anynews v2.13.0
Post by: cwsoft on July 15, 2014, 06:11:45 PM
Hello,

cwsoft-anynews v2.13.0 stable is available at GitHub (https://github.com/cwsoft/wb-cwsoft-anynews) and the WebsiteBaker Add-ons repository (http://addon.WebsiteBaker.org/pages/en/browse-add-ons.php?id=0C80D11).

Updates since last release:
- added utility function getGroupIdTypes() to display group_type_ids usable with Anynews
- updated 3rd party package Twig to latest version

The utility function getGroupIdTypes can be used to output news title and all possible Anynews group_type_ids (post_id, section_id, page_id, group_id) by adding the following code into a page/section of type code. The utility function was added to allow the easier extraction of group_ids and post_ids in newer WebsiteBaker News module versions (ids were changed from integer to a hashed value).

Code: [Select]
require_once(WB_PATH . '/modules/cwsoft-anynews/code/anynews_functions.php');
getGroupIdTypes($sort_column = "post_id", $sort_order = "ASC", $output = true);

Use this function to find out the group_ids or post_ids of specific news items you want to output with Anynews.

For details see README at GitHub (https://github.com/cwsoft/wb-cwsoft-anynews#anynews-configuration).

cwsoft
Title: Re: Snippet: cwsoft-anynews
Post by: daydreamer on July 25, 2014, 12:39:16 PM
How to show date as 1 JUL only? I have changed date settings it WB admin but no change
Title: Re: Snippet: cwsoft-anynews
Post by: Gast on July 25, 2014, 12:52:49 PM
look into the language file from the anynews module

Quote
'DATE_FORMAT'            => 'H:i, d.m.Y'
Title: Re: Snippet: cwsoft-anynews
Post by: daydreamer on July 25, 2014, 01:10:22 PM
Thanks jacobi22 changed to d/m but would like to show month as Jul not as number
Title: Re: Snippet: cwsoft-anynews
Post by: daydreamer on July 25, 2014, 01:14:32 PM
Got it read phpmanual it's F
Title: Re: Snippet: cwsoft-anynews
Post by: Ruud on July 25, 2014, 01:15:44 PM
All options: http://php.net/manual/en/function.date.php

This would give "25 Jul" for today.
Code: [Select]
'DATE_FORMAT'            => 'j M'
Note it will use your servers "Locale" setting (language).
Title: Re: Snippet: cwsoft-anynews
Post by: G4 on August 05, 2014, 04:49:26 PM
Is it possible to place news items next to each other? I have included an image.
Title: cwsoft-anynews v2.13.1 released
Post by: cwsoft on September 16, 2014, 01:57:27 PM
Hi,

cwsoft-anynews v2.13.1 stable is available at GitHub (https://github.com/cwsoft/WebsiteBaker-anynews) and the WebsiteBaker Add-ons repository (http://addon.WebsiteBaker.org/pages/en/browse-add-ons.php?id=0C80D11).

Updates since last release:
- added fixes for handling of anynews Droplet parameters (special chars like <>, boolean paramters)
- thanks to jacobi22 and dbs for the bug reports

Further details can be found in the README at GitHub (https://github.com/cwsoft/wb-cwsoft-anynews#anynews-configuration).

cwsoft
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on September 16, 2014, 02:01:29 PM
Hi,

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.

Cheers cwsoft
Title: cwsoft-anynews v2.13.2 released
Post by: cwsoft on October 02, 2014, 06:43:18 PM
Hi,

cwsoft-anynews v2.13.2 stable is available at GitHub (https://github.com/cwsoft/WebsiteBaker-anynews) and the WebsiteBaker Add-ons repository (http://addon.WebsiteBaker.org/pages/en/browse-add-ons.php?id=0C80D11).

Updates since last release:
- fixed a typo in function_exists parameter (thanks to Luisehahne for reporting)

Further details can be found in the README at GitHub (https://github.com/cwsoft/wb-cwsoft-anynews#anynews-configuration).

cwsoft
Title: Re: Snippet: cwsoft-anynews
Post by: Roych on October 10, 2014, 12:19:40 AM
Here is a Slovenian (not Slovakia) translation ;)  SI.php

Code: [Select]
<?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'
);

Greetings from Slovenia  :wink:

R
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on October 10, 2014, 12:56:43 PM
@Roych: Thanks a lot for your Slovenian translation. Will include it with the next cwsoft-anynews version. Highly appreciated.

Cheers cwsoft
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on October 10, 2014, 05:52:16 PM
@Roych: Pushed the Slovenian Anynews language file (https://github.com/cwsoft/WebsiteBaker-anynews/commit/8f62c2067467623f64244c91f79bdc3366607bc5) to my GitHub repo.

Cheers cwsoft

Title: Re: Snippet: cwsoft-anynews
Post by: Roych on October 13, 2014, 02:38:53 PM
Hello

I appreciate it ;) But there is a small mistake on your https://github.com/cwsoft/WebsiteBaker-anynews#anynews-configuration (https://github.com/cwsoft/WebsiteBaker-anynews#anynews-configuration)

with the .php name within the credits:
You wrote:
Slovenian translation (SL.php) ---> It should be SI.php not SL (SL is for Slovakia)
Just so you know ;)

Small mistake lots of people are mistaken by this  :wink:

cheers
Roych
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on October 14, 2014, 09:15:15 PM
Hi Roych,

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).

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.

Cheers cwsoft
Title: Re: Snippet: cwsoft-anynews
Post by: Roych on October 15, 2014, 01:46:08 PM
Hi

Not really sure but SL is not working. I always use SI for Slovenian language and is working great
Se here: http://countrycode.org/slovenia (http://countrycode.org/slovenia)
SL is used for Siera Leone  :-P

Sory for SK (Slovakia) my mistake.

And it shows me the right flag also if I use SI so it must be right... When I add the changed SL language file in the Root WB Language folder it wont even show up ...

And all Slovenian domain names and all related to this has an .SI at the end.

But maybe someone can confirm this.

thx
Roych
Title: Re: Snippet: cwsoft-anynews
Post by: Gast on October 15, 2014, 03:02:29 PM
language codes (http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) are not the same like country codes (http://countrycode.org/)

if you add a new language in WB, its not only the upload you have to registered as a addon
go to addons -> advanced -> Designs
Title: Re: Snippet: cwsoft-anynews
Post by: DarkViper on October 15, 2014, 07:02:00 PM
Quote
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).
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.
ISO 639-1 is correct for all WB-Versions up to 2.8.4 and later
From 2.9 (somewhen in future) we start to allow codes defined in RFC4234 following this pattern:
2*3ALPHA (ISO 639-1 | 639-2/T) language
2ALPHA (ISO3166) region
3*5alphanum (registered Variants) variant

Manuela
Title: Re: Snippet: cwsoft-anynews
Post by: Roych on October 16, 2014, 05:29:00 PM
Understand, thx for the info, then Im always using the SI language name that is wrong, hehe
Never had any problems thou..
Well It's true that I always translate my language files because there aren't any for Slovenia for WB yet.

thx  :wink:

R
Title: cwsoft-anynews v2.14.0 released
Post by: cwsoft on January 20, 2015, 09:52:22 PM
Hi,

the new version cwsoft-anynews v2.14.0 is available at GitHub (https://github.com/cwsoft/WebsiteBaker-anynews#README) and the WebsiteBaker Add-ons repository (http://addon.WebsiteBaker.org/pages/en/browse-add-ons.php?id=0C80D11).

Updates since last release:
 - fixed typo in function_exists call introduced with v2.8.0 (thanks to Luisehahne)
 - added Slovenian language file provided by forum member Roych
 - replaced outdated better-coda-slider with Liquid Slider plugin
 - renamed flexslider configuration files to align with Liquid Slider
 - updated 3rd party package Twig to v1.17.0

Further details can be found in the README at GitHub (https://github.com/cwsoft/WebsiteBaker-anynews#README).

cwsoft
Title: Trouble creating custom configuration array in ver. 2.14.0
Post by: J.R. on March 01, 2015, 11:57:43 PM
I'm afraid I find the current help/documentation for the ver. 2.14.0 found at Githum.com to be a little confusing. I think I need to create a "custom configuration arrary" in the AnyNews call I have placed in my template's index.php file, but so far nothing I have tried works. Does someone have a sample of a working custom configuration array for use in an template they could share?

Below this paragraph I'll show the code in my template's index.php I am currently using. It is a 3 column template with the left and right columns supposed to display news items from two different groups And it works fine... except what happens is that *both* groups are displayed in *both* columns, instead of group_id = 1 displaying in the left column and group_id = 2 displaying in the right column as specified --

<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')) {
      echo getNewsItems(
      $group_id = 1,
       $display_mode = 1);
      }
       ?>
                  
   </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')) {
   echo getNewsItems(
   $group_id = 2,
   $display_mode = 1);
   }
   ?>
                  
   </div><!-- end display_anynews -->      
               
   </div><!-- end rightsidebox -->

   </div><!-- end leftsideColumn -->

So, as I said, the above works fine... except what happens is that *both* groups are displayed in *both* columns, instead of group_id = 1 displaying in the left column and group_id = 2 displaying in the right column.

I think a custom configuration array is what I need to make it work that way, but am at a loss just how to add the configuration code to my template's index.php file.

-- J.R.
Title: Re: Snippet: cwsoft-anynews
Post by: dbs on March 02, 2015, 10:02:10 AM
Hi, i do the same but with the droplet.
Have 3 columns and show 3 groups. works. looks like this.
[[getNewsItems?group_id=13&display_mode=4&max_news_items=5&strip_tags=false]]

But your code should also work.

Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on March 02, 2015, 03:37:31 PM
Hi,

just use the code shown in example section at GitHub (https://github.com/cwsoft/WebsiteBaker-anynews#anynews-configuration) should do the trick.

So instead of:
Code: [Select]
<?php
if (function_exists('getNewsItems')) {
    echo 
getNewsItems(
        
$group_id 1,
        
$display_mode 1);
}
?>


just use:
Code: [Select]
<?php
if (function_exists('getNewsItems')) {
$config = array(
'group_id' => 1,
'display_mode' => 1,
);
echo getNewsItems($config);
}
?>


in your template. For the second block, adjust the 'group_id' parameter to fit your needs.

Cheers
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on March 02, 2015, 06:17:25 PM
Hi,

just for awareness. I decided to stop my activities around WebsiteBaker and hence the maintenance of my cwsoft-xxx-modules end of January 2015 as announced in this thread (http://forum.WebsiteBaker.org/index.php/topic,27995.msg194919.html#msg194919).

If somebody wants to maintain any of my modules, feel free to do so under the GNU GPL license :-) No need to get in contact me for allowance, just do it in the spirit of Open Source.

Cheers cwsoft
Title: Re: Snippet: cwsoft-anynews
Post by: J.R. on March 03, 2015, 10:56:32 AM
dbs,
I was thinking about trying a droplet, but really would prefer to hard-coded this into my template for various administrative reasons.

cwsoft,
Thanks for the code sample. And *many* more thanks for all the time and effort you've put into making WB a better CMS over the years. You will be sorely missed :cry:

I did try creating the array as you've shown and it didn't work for me -- but I tried it again by copying your example and it *worked* just fine!  Hmmm... maybe before I left the $ in front of group_id and display_mode?

I'm unsure about the reason for using => instead of just = in a line like:

'group_id' => 1,

?

-- J.R.


Title: Re: Snippet: cwsoft-anynews
Post by: Gast on March 03, 2015, 11:40:03 AM
see here -> PHP Array (http://php.net/manual/en/language.types.array.php)
Title: Re: Snippet: cwsoft-anynews
Post by: Gast on March 03, 2015, 12:19:02 PM
the function getNewsItems() needs a config-array or it works with the basic setting (see include.php of the module)

your first code like
Code: [Select]
if (function_exists('getNewsItems')) {
    echo getNewsItems(
        $group_id = 3,
        $display_mode = 1);
}

built not a valid array, because of that, the scripts stop and send a error message to the browser (only visible, if your error reporting in WB-Setting-> Advanced is switch to a option with E_ALL

your code from post#188 will work, if you replace both invalide php-part's with the code from cwsoft like this

Code: [Select]
<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 -->

other method (see post from dbs) is a droplet call (needs to add the droplet code from the top of the file modules/cwsoft-anynews/droplet/cwsoft-anynews-droplet.php (comment area in line's 3-9) as a new droplet in admin-tools -> droplets

example for the droplet call

Code: [Select]
[[getNewsItems?group_id=1&display_mode=1]]
Title: Re: Snippet: cwsoft-anynews
Post by: J.R. on March 04, 2015, 01:02:37 AM
Jacobi22,

I've created arrays before in other programming languages, but never had the occasion to do it in PHP before.
and seeing:

'group_id' => 1,

instead of

'group_id' = 1,

...seems strange to me because I would think than in this case you would only want the comparison to return

TRUE
 if 'group_id' is equal to "4"

...rather than have the comparison return

TRUE
 if 'group_id' is equal to or greater than "4",

In fact, in the old version of AnyNews ( which used displayNewsItems ) the "=" was the syntax used:

if (function_exists('displayNewsItems')) {
    displayNewsItems(
    $group_id = 4,
    $display_mode = 1);
     }
 
                  





Title: Re: Snippet: cwsoft-anynews
Post by: Gast on March 04, 2015, 09:56:42 AM
feel free to do, what ever you want.
we show a working solution  if you take it, it works
Title: Re: Snippet: cwsoft-anynews
Post by: DarkViper on March 04, 2015, 11:00:07 AM
I've created arrays before in other programming languages, but never had the occasion to do it in PHP before.

...seems strange to me because I would think than in this case you would only want the comparison to return
We use PHP as programming language. So the syntax of PHP is mandatory to use. Other languages does not interest us.

a good help the Language Reference from PHP manual (http://php.net/manual/en/langref.php) can be.

Manuela
Title: Re: Snippet: cwsoft-anynews
Post by: J.R. on March 04, 2015, 10:36:03 PM
 :|  Some misunderstanding here... possibly because of native language differences? If you look at my post here on March 3 at 10:56:32 am you will see that I *did* take the solution offered (gratefully) and wrote:

'... I tried it again by copying your example and it *worked* just fine!"

and I also thanked cwsoft for providing the example of the correct syntax used to create a custom configuration array.

Then I asked a question about the use of  "=>" in his example, because not having done much PHP coding I had never run into that operator before. Since I know that PHP *does* use the "=" sign in other cases I didn't realize that it also uses "=>" as a special kind of equal sign. In every other programming language => or <= means "equal to or greater than"

But after following the links jacobi22 and Manuela provided, I now also know that PHP can also use "==" and "===" for tighter control, since plain old "=" in PHP can return "loose" results.

If someone had said, "That's just another way PHP says equal to" I would have understood. I know all languages have their own unique quirks.

And, guys, I never suggested using some other language besides PHP -- I was  just trying to better understand PHP and cwsoft's code example.  :-)

-- J.R.
Title: Re: Snippet: cwsoft-anynews
Post by: Stefek on March 04, 2015, 11:08:21 PM
Hello JR,

in PHP => is not an operator in the context of array building.

It's better you look the different ways how arrays are put together in PHP instead of looking for logical operators.

http://php.net/manual/en/language.types.array.php

All the confusion and mixup should align pretty well after you do.

Kind Regards,
Stefek
Title: Re: Snippet: cwsoft-anynews
Post by: J.R. on March 05, 2015, 08:43:40 AM
Stefek,

Thanks for the link.. that page makes fascinating reading and I learned a lot. But I had to laugh when I found the following code given as an example of comparative arrays on that page:


<?php
// This:
$a = array( 'color' => 'red',
            'taste' => 'sweet',
            'shape' => 'round',
            'name'  => 'apple',
            4        // key will be 0
          );

$b = array('a', 'b', 'c');


// . . .is completely equivalent with this:


$a = array();
$a['color'] = 'red';
$a['taste'] = 'sweet';
$a['shape'] = 'round';
$a['name']  = 'apple';
$a[]        = 4;        // key will be 0

$b = array();
$b[] = 'a';
$b[] = 'b';
$b[] = 'c';

// After the above code is executed, $a will be the array
// array('color' => 'red', 'taste' => 'sweet', 'shape' => 'round',
// 'name' => 'apple', 0 => 4), and $b will be the array
// array(0 => 'a', 1 => 'b', 2 => 'c'), or simply array('a', 'b', 'c').
?>


 :-) So it goes, in coding as in life...

-- J.R.
Title: Re: Snippet: cwsoft-anynews
Post by: Stefek on March 05, 2015, 06:08:51 PM
Hello JR,

yes, those are equivalent, both.

Not as a rule, but commonly the former will be used to initialize an array and the latter to overwrite values that have been before in the array.
Of course you may as well use the latter style to generate an array from scratch (for the anyNews settings or wherever you like).

But make no mistake, you again call them comparative arrays. They are not "comparative" in the sense of data-comparision. They rather are (multidimensional) data collections with key=>value pairs where the value can itself become an array on a lower level.

Kind regards,
Stefek
Title: Re: Snippet: cwsoft-anynews
Post by: J.R. on March 07, 2015, 08:10:39 PM
Stefek,

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.

I will be following the syntax protocol which you pointed out is the most common now that I understand it -- it's always good in coding to following the most widely used syntax when possible.

On the page you recommended I found out something else I did not realize about PHP, where it says:

"Comparing --
It is possible to compare arrays with the array_diff() function and with array operators."


I know my question has taken this thread a little off topic, so I will end by saying that prior to asking about the purpose of "=>" I had no idea there were so many different ways to say "equal to" in PHP, so this had been a very valuable discussion for me and I thank everyone who replied.  :-)

-- J.R.
Title: Re: Snippet: cwsoft-anynews
Post by: DarkViper on March 07, 2015, 09:46:15 PM
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.

It's easy to misunderstand the syntay and meaning of =>
Normaly => is a simple 'equal or greater then' operator which compares values (==> compares values and data types).
Now a little confusion from PHP:
In case of defining an array => is a assignment operator without compare functionality.


Manuela
Title: Re: Snippet: cwsoft-anynews
Post by: nibz on June 29, 2015, 08:01:12 PM
Updated the repo: https://github.com/WebsiteBaker-modules/anynews

Changes:
+ Updated the readme links to the correct repo.
+ Updated the module info to link to the correct github repo
+ Updated the droplet: Added possibility to select the years to display
(thanks to marmot)
Title: Re: Snippet: cwsoft-anynews
Post by: Gast on June 29, 2015, 08:03:26 PM
thx to marmot & nibz
Title: Re: Snippet: cwsoft-anynews
Post by: nibz on June 29, 2015, 08:11:14 PM
The problems now with the server are a good reason for my github project ;-).
I hope more people will join and make pull-requests to the github repo.
It's not my goal to replace the addons repo but in downtime we could at least get the latest module code :).

WebsiteBaker for the win!
Title: Re: Snippet: cwsoft-anynews
Post by: gnom on January 31, 2016, 10:47:40 AM
can someone help me? I want to show only the last trhee 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?

Title: Re: Snippet: cwsoft-anynews
Post by: Gast on January 31, 2016, 06:22:55 PM
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?

i use there the flexslider, but not sure, is this the original in the file display-mode4 or not

if yes and in my case: the flexslider builds a div around your selected news btw the content-short. this div use padding for the distance to the top, bottom, left and right
its defined in the file css/custom-settings-flexslider.css with
my example
Code: [Select]
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;}

newsslider is here a extra div, was better for me to configured. (so be carefull, if you use Copy&paste)
the paddings means: build a distance from the displayed text to the borders with 15px, and 70px from the left border ( i use there a small background-image)
its important, to have no fixed height for the slider, defined in the base settings of this flexslider-div, if you need a height, use min-height (its work's for shorter messages with only one line)
Code: [Select]
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;
}

i didnt use a definition for the max-height or height , i use there max-lenght in the droplet-call (in my case not longer then two line's - with these font on this page ~160 chars)

a good help is a plugin like firebug or webdeveloper-Toolbar to found the used settings for this box
flexslider use a basic-setting in flexslider.css in the thirdparty-folder
and a custom-settings.flexslider.css in the css-folder of this module
but its also possible to set all this in your template.css

if my post doesnt help, please post the URL to the "problem-"page here or via PM
Title: Re: Snippet: cwsoft-anynews
Post by: gnom on February 01, 2016, 07:16:58 AM
thanks will try in the eventing and hope it will work.

Title: Re: Snippet: cwsoft-anynews
Post by: gnom on February 02, 2016, 06:48:01 PM
hmm okay... found out now the css that makes it too "height" is in css thirdparty/flexslider ... don't want to change there something. So ... don't know what to do .. think will check it on weekend again .... or send you link.  if anyone has a "special" own template for anynews (htt-file) and the css for it - feel free to send it to me :-D thanks!
Title: Re: Snippet: cwsoft-anynews
Post by: cwsoft on February 03, 2016, 10:07:18 PM
@gnom: you don't need to change the Flexslider CSS files. Just adapt cwsoft-anynews/css/flexslider-custom.css (https://github.com/cwsoft/wbce-anynews/blob/master/cwsoft-anynews/css/flexslider-custom.css) to fit your needs. This file is loaded after the original Flexslider CSS file and hence able to overwrite the defaults to your needs.

Cheers
Title: Re: Snippet: cwsoft-anynews
Post by: rumen on December 19, 2016, 09:50:14 PM
I couldn't call an image I saved in /media. In custom htt template I put {GROUP_IMAGE}, but the image doesn't appear. What I did wrong?

Second the iamge can be only one for all news as group image or I can put different image in the all news and call the image with tne news?

In the attached zip file "offers" there are files files "top_offers" - how it should be (the pictures are not yet there, but it is visible where they should appear). In the "test_offers" is my result at the moment.

Regards,
Title: Re: Snippet: cwsoft-anynews
Post by: Gast on December 19, 2016, 10:29:29 PM
please use a browser tool like firebug or key F12 to look into this elements, search there for the path to the image(s)
maybe its a path like this:

Quote
src="{SYSVAR:MEDIA_REL}/you_image.jpg"

and not with the real domain adress
Title: Re: Snippet: cwsoft-anynews
Post by: rumen on December 19, 2016, 11:47:12 PM
Pictures are uploaded in /media

And the code should call them from /media (as the news module see them and show them on the screen or not?).

This is the htt:

Code: [Select]
<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>
Title: Re: Snippet: cwsoft-anynews
Post by: Gast on December 19, 2016, 11:54:33 PM
what i mean, is the output in your frontend with the missing pictures
Title: Re: Snippet: cwsoft-anynews
Post by: rumen on December 20, 2016, 12:16:14 AM
Here is the HTML code

Code: [Select]
<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>
Title: Re: Snippet: cwsoft-anynews
Post by: rumen on December 20, 2016, 12:19:09 AM
It is very strange, but I don't see any iamge file there and the code should call the image.

Code: [Select]
<tt></tt>{GROUP_IMAGE}<br />
Maybe the code here is wrong.
Title: Re: Snippet: cwsoft-anynews
Post by: rumen on December 20, 2016, 10:34:53 AM
Most probably I'm doing a simple and stupid syntax error somewhere .... Can you give me an example how the syntax should be if I have picture in /media folder called "test.jpg" in this code:

Code: [Select]
$custom_placeholder = array('IMG_LINK' => '%img%', 'MY_VAR' => '#(test)#i'
Title: Re: Snippet: cwsoft-anynews
Post by: dbs on December 20, 2016, 10:50:07 AM
How old is your anynews or wb?
In newest versions it looks like this
Code: [Select]
{{ news.GROUP_IMAGE }}
Title: Re: Snippet: cwsoft-anynews
Post by: rumen on December 20, 2016, 11:12:53 AM
This one: http://www.websitebakers.com/pages/code-snippets/listings/anynews.php?searchresult=1&sstring=anynews

CMS Version 2.8.3 SP1
Revision 1638
Admin version 1.6
Title: Re: Snippet: cwsoft-anynews
Post by: rumen on December 20, 2016, 11:38:26 AM
A well we have 2 codes, right? One is for use the module and the other is for htt template.

For use it:

Code: [Select]
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
   );

Where I have to put custom placeholder the image I want .... and in the help file is given that example:

Code: [Select]
$custom_placeholder = array('IMG_LINK' => '%img%', 'MY_VAR' => '#(test)#i'
and we have htt template:

Code: [Select]
<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>

Do you suggest to change {GROUP_IMAGE} with {{ news.GROUP_IMAGE }} in the htt file?
Title: Re: Snippet: cwsoft-anynews
Post by: dbs on December 20, 2016, 11:41:46 AM
Your PHP version is 5.4 or lesser i think.
Nobody should work with these old and unsecure systems like yours.
I can't help. Maybe you think about upgrading WB and modules?
Title: Re: Snippet: cwsoft-anynews
Post by: rumen on December 20, 2016, 12:50:14 PM
My PHP is 5.6 but it is on my localhost under XAMPP server. After I'm ready I will transfer the site to host where I can set PHP ver. to 7 if I want. WB I can upgrade to 2.8.3-SP7 - but do you think this will resolve the issue?
Title: Re: Snippet: cwsoft-anynews
Post by: rumen on December 20, 2016, 01:29:27 PM
OK I upgraded to

CMS Version 2.8.3 SP7
Revision 1646
Admin version 1.6

But the p[roblem is the same and the code table is destroied shows all cyrrilic letters as ???????? but I will fix that ... in framework/calss.database under run quiry I need to add:

Code: [Select]
$set = @mysql_query ('SET NAMES utf8');
$set = @mysql_query ('SET COLLATION_CONNECTION=utf8_general_ci');

But will need to write again everything. Thanks God is not big deals, the text is small.
Title: Re: Snippet: cwsoft-anynews
Post by: Gast on December 20, 2016, 01:40:07 PM
the code from dbs is part of the twig-version -> {{ news.GROUP_IMAGE }},  see the double brackets here. your version is older and use phplib. twig and phplib are "translators" for the placeholders and different methodes, not possible, to mix it. phplib use a single brackets like {} or [] around a placeholders. the most templates in the wb-backend using phplib, newer modules like new wrapper, mod_multilingual using twig
in attachement a older version of anynews, the latest before cwsoft stops this project here. is has twig as thirthparty onboard, so its possible to run in older wb-versions without twig in the package.
twig is now part of wb since SP4 (?)

in this version i use another parameter called start_item. thia parameter make it possible, to start the output somewher in the loop of the news. for example: a first standard function call show's the first 5 elements of the news, in a second call, i use the start_item-parameter with the value == 6, it means: show me the X next elements, but start at element number 6.

here some  examples code for the output, using in a project in different sections, first call run's in a slider and shows only special news for this slider

at first a standard call
show all item from group = 2, in display_mode = 4, order=descending, max lenght = 170 chars
Code: [Select]
[[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>]]
after a wysiwyg section, a block with only 4 news in a teaser line
next a limit of 4
show only 4 news from group 1
Code: [Select]
[[getNewsItems?group_id=1&display_mode=5&max_news_items=4&sort_by=1&sort_order=1&start_item=0&not_older_than=999&max_news_length=150]]

after a grafic element, i need some more news in a second teaser block
the example with the start item
show maximal two news from group_id = 1, start with number 4
Code: [Select]
[[getNewsItems?group_id=1&display_mode=5&max_news_items=2&sort_by=1&sort_order=1&start_item=4&not_older_than=999&max_news_length=150]]
Title: Re: Snippet: cwsoft-anynews
Post by: rumen on December 21, 2016, 01:02:09 PM
I did it with the old ver. Somehow I could make it with some formating, group picture (all posts will use one and the same, but ...) . It is not exactly as I wished, but it is ok!

Will look something like that:

(http://zapryanov.tk/media/job2_top_offers.png)

Thanks for the help!