Snippet: cwsoft-anynews

cwsoft

#52
Hi Argos,

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

QuoteIt 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

Argos

#51
Quote from: cwsoft on June 06, 2012, 07:38:53 PM
I basically just copied over your initial Dutch language files you posted here without further checking.

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

QuoteNot 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]
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!

cwsoft

#50
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 without further checking. According the PHP date manual, 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

Argos

#49
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.
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!

cwsoft

#48
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

cwsoft

#47
Hi,

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

Quote from: argosIt 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: argosIt'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: argosI 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

Argos

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.
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!

DarkViper

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

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 -
[url=http://www.youtube.com/watch?v=tmzDAz6ZvFQ]Der blaue Planet[/url] - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen[br]
[i]"You have to take the men as they are... but you can not leave them like that !" :-P [/i]
[i]Das tägliche Stoßgebet: [b]Oh Herr, wirf Hirn vom Himmel ![/b][/i]

Stefek

Thanks Werner. That's what I thought should be possible.
QuoteHave 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
[i]"Gemeinsam schafft man mehr."[/i]

[b][url=http://duden.de/rechtschreibung/gemeinsam#Bedeutung1]gemeinsam[/url][/b]
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Argos

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.
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!

DarkViper

A little bit shorter:   ;-)

<?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. ;-)
[url=http://www.youtube.com/watch?v=tmzDAz6ZvFQ]Der blaue Planet[/url] - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen[br]
[i]"You have to take the men as they are... but you can not leave them like that !" :-P [/i]
[i]Das tägliche Stoßgebet: [b]Oh Herr, wirf Hirn vom Himmel ![/b][/i]

Stefek

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:


<?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
[i]"Gemeinsam schafft man mehr."[/i]

[b][url=http://duden.de/rechtschreibung/gemeinsam#Bedeutung1]gemeinsam[/url][/b]
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

DarkViper

Quote from: Stefek on May 06, 2012, 10:25:02 PM

suggestion:

<?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... ;-)
<?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...  ;-)
[url=http://www.youtube.com/watch?v=tmzDAz6ZvFQ]Der blaue Planet[/url] - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen[br]
[i]"You have to take the men as they are... but you can not leave them like that !" :-P [/i]
[i]Das tägliche Stoßgebet: [b]Oh Herr, wirf Hirn vom Himmel ![/b][/i]

Stefek

OK.

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

Regards,
Stefek
[i]"Gemeinsam schafft man mehr."[/i]

[b][url=http://duden.de/rechtschreibung/gemeinsam#Bedeutung1]gemeinsam[/url][/b]
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

cwsoft

#38
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

Stefek

#37
Hello,
I have a suggestion to make which will make this snippet even more user friendly.

In file include.php
LINE 75

suggestion:

<?php // ignore opening tag

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


and 83 ff.


<?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
[i]"Gemeinsam schafft man mehr."[/i]

[b][url=http://duden.de/rechtschreibung/gemeinsam#Bedeutung1]gemeinsam[/url][/b]
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

cwsoft

#36
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. 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
- download latest installation package
- view or post known issues

Feedback welcome.

Cheers

daydreamer

@cwsoft this works great

'TITLE' => substr(($strip_tags) ? strip_tags($row['title']) : $row['title'], 0, X),

Thanks

daydreamer


marmot

Hi,
Quote from: daydreamer on May 01, 2012, 03:43:31 PM
Thanks for the update of anynews, one question is it possible to truncate the title?
I made this droplet for truncating the shorttext of news module without using jQuery. Maybe you can adapt it for your needs.

regards

cwsoft

#32
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. Reciept for implementation similar to this post.

Another option is to add this feature to your cwsoft-anynews module code by wrapping the PHP function substr around this code line as shown below (replace X with numbers of characters to show):

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

{{ news.TITLE | slice(0,X) }}


Cheers

daydreamer

Thanks for the update of anynews, one question is it possible to truncate the title?

Thanks

cwsoft

#30
Hello,

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

Create a template with jQuery Smart-Paginator Plugin:
1. download jQuery 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

sky writer

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?

cwsoft

#28
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