Author Topic: Snippet: cwsoft-anynews  (Read 151796 times)

Offline Argos

  • Posts: 2542
  • Gender: Male
    • Argos Media
Re: Codesnippet: cwsoft-anynews
« Reply #75 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...
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!

Offline Bug

  • Posts: 237
Re: Codesnippet: cwsoft-anynews
« Reply #76 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


Offline cwsoft

  • Posts: 605
Re: Codesnippet: cwsoft-anynews
« Reply #77 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 (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

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 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 - 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 (and reverted if needed). However, I do hope that some of the actual issues will sort out once the brand new WebsiteBaker repository 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 and Anynews 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
« Last Edit: September 04, 2012, 08:20:41 PM by cwsoft »

Offline Bug

  • Posts: 237
Re: Codesnippet: cwsoft-anynews
« Reply #78 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

Offline cwsoft

  • Posts: 605
Re: Snippet: cwsoft-anynews
« Reply #79 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 in this thread.

Cheers

Offline ruebenwurzel

  • Betatester
  • **
  • Posts: 8412
  • Gender: Male
  • Keep on Rockin
    • Familie Gallas Online
Re: Snippet: cwsoft-anynews
« Reply #80 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

Offline marmot

  • Posts: 1103
Re: Snippet: cwsoft-anynews
« Reply #81 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

Offline ruebenwurzel

  • Betatester
  • **
  • Posts: 8412
  • Gender: Male
  • Keep on Rockin
    • Familie Gallas Online
Re: Snippet: cwsoft-anynews
« Reply #82 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

Offline badknight

  • WebsiteBaker Org e.V.
  • **
  • Posts: 819
  • Gender: Male
    • pinzweb
Re: Snippet: cwsoft-anynews
« Reply #83 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
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.



Ich würde gern die Welt verändern, doch Gott gibt mir den Quellcode nicht...

Offline cwsoft

  • Posts: 605
Changes at GitHub
« Reply #84 on: December 17, 2012, 08:00:29 PM »
For your information.

GitHub recently dropped support for managed downloads. 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. 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, or download the GitHub archive, unzip it locally and rezip it without the parent folder to make it a installable WebsiteBaker archive yourself.

Cheers
« Last Edit: December 17, 2012, 08:02:00 PM by cwsoft »

Offline firefoxfx

  • Posts: 6
Re: Snippet: cwsoft-anynews
« Reply #85 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

Offline cwsoft

  • Posts: 605
Re: Snippet: cwsoft-anynews
« Reply #86 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.

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

« Last Edit: January 27, 2013, 08:33:20 PM by cwsoft »

Offline firefoxfx

  • Posts: 6
Re: Snippet: cwsoft-anynews
« Reply #87 on: January 27, 2013, 08:43:19 PM »
thanks cwsoft, i copied the order from the read me and that did the trick.

Offline dana

  • Posts: 53
    • Webdesign by Dana
Re: Snippet: cwsoft-anynews
« Reply #88 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'
);

Offline dana

  • Posts: 53
    • Webdesign by Dana
Re: Snippet: cwsoft-anynews
« Reply #89 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! :)

Offline cwsoft

  • Posts: 605
Re: Snippet: cwsoft-anynews
« Reply #90 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. As I released Anynews 2.7.0 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 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
« Last Edit: February 04, 2013, 07:04:30 PM by cwsoft »

Offline dana

  • Posts: 53
    • Webdesign by Dana
Re: Snippet: cwsoft-anynews
« Reply #91 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 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. :(

Offline cwsoft

  • Posts: 605
Re: Snippet: cwsoft-anynews
« Reply #92 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 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
« Last Edit: February 07, 2013, 07:08:02 AM by cwsoft »

Offline cwsoft

  • Posts: 605
Re: Snippet: cwsoft-anynews
« Reply #93 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. 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
« Last Edit: February 07, 2013, 10:16:07 PM by cwsoft »

Offline owk444

  • Posts: 20
  • Gender: Male
Re: Snippet: cwsoft-anynews
« Reply #94 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. :-(

Offline dana

  • Posts: 53
    • Webdesign by Dana
Re: Snippet: cwsoft-anynews
« Reply #95 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 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. :)


Offline owk444

  • Posts: 20
  • Gender: Male
Re: Snippet: cwsoft-anynews
« Reply #96 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.

Offline cwsoft

  • Posts: 605
Re: Snippet: cwsoft-anynews
« Reply #97 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
« Last Edit: February 08, 2013, 08:45:51 PM by cwsoft »

Offline owk444

  • Posts: 20
  • Gender: Male
Re: Snippet: cwsoft-anynews
« Reply #98 on: February 08, 2013, 08:06:54 PM »
Thank you for droplet code! It works fine!

Description in the file translated. File attached.

Offline cwsoft

  • Posts: 605
Re: Snippet: cwsoft-anynews
« Reply #99 on: February 08, 2013, 08:44:35 PM »
@owk444: Thanks for the Russian langauge file. Uploaded it to GitHub repository, so it will be issued with the next release.

Cheers