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

Offline cwsoft

  • Posts: 605
cwsoft-anynews v2.13.1 released
« Reply #175 on: September 16, 2014, 01:57:27 PM »
Hi,

cwsoft-anynews v2.13.1 stable is available at GitHub and the WebsiteBaker Add-ons repository.

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.

cwsoft

Offline cwsoft

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

Cheers cwsoft

Offline cwsoft

  • Posts: 605
cwsoft-anynews v2.13.2 released
« Reply #177 on: October 02, 2014, 06:43:18 PM »
Hi,

cwsoft-anynews v2.13.2 stable is available at GitHub and the WebsiteBaker Add-ons repository.

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.

cwsoft

Offline Roych

  • Betatester
  • **
  • Posts: 573
  • Gender: Male
Re: Snippet: cwsoft-anynews
« Reply #178 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

Offline cwsoft

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

Offline cwsoft

  • Posts: 605
Re: Snippet: cwsoft-anynews
« Reply #180 on: October 10, 2014, 05:52:16 PM »
@Roych: Pushed the Slovenian Anynews language file to my GitHub repo.

Cheers cwsoft


Offline Roych

  • Betatester
  • **
  • Posts: 573
  • Gender: Male
Re: Snippet: cwsoft-anynews
« Reply #181 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

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

Offline cwsoft

  • Posts: 605
Re: Snippet: cwsoft-anynews
« Reply #182 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, also see WIKI.

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

Offline Roych

  • Betatester
  • **
  • Posts: 573
  • Gender: Male
Re: Snippet: cwsoft-anynews
« Reply #183 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
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
« Last Edit: October 15, 2014, 01:59:40 PM by Roych »

Offline Gast

  • Posts: 5920
Re: Snippet: cwsoft-anynews
« Reply #184 on: October 15, 2014, 03:02:29 PM »
language codes are not the same like country codes

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

Offline DarkViper

  • Forum administrator
  • *****
  • Posts: 3062
  • Gender: Female
Re: Snippet: cwsoft-anynews
« Reply #185 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, also see WIKI.
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
Der blaue Planet - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen

"You have to take the men as they are… but you can not leave them like that !" :-P
Das tägliche Stoßgebet: Oh Herr, wirf Hirn vom Himmel !

Offline Roych

  • Betatester
  • **
  • Posts: 573
  • Gender: Male
Re: Snippet: cwsoft-anynews
« Reply #186 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

Offline cwsoft

  • Posts: 605
cwsoft-anynews v2.14.0 released
« Reply #187 on: January 20, 2015, 09:52:22 PM »
Hi,

the new version cwsoft-anynews v2.14.0 is available at GitHub and the WebsiteBaker Add-ons repository.

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.

cwsoft

Offline J.R.

  • Posts: 24
Trouble creating custom configuration array in ver. 2.14.0
« Reply #188 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.

Offline dbs

  • Betatester
  • **
  • Posts: 8639
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: Snippet: cwsoft-anynews
« Reply #189 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.


Offline cwsoft

  • Posts: 605
Re: Snippet: cwsoft-anynews
« Reply #190 on: March 02, 2015, 03:37:31 PM »
Hi,

just use the code shown in example section at GitHub 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

Offline cwsoft

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

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
« Last Edit: March 02, 2015, 06:28:19 PM by cwsoft »

Offline J.R.

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


« Last Edit: March 03, 2015, 11:11:43 AM by J.R. »

Offline Gast

  • Posts: 5920
Re: Snippet: cwsoft-anynews
« Reply #193 on: March 03, 2015, 11:40:03 AM »
see here -> PHP Array

Offline Gast

  • Posts: 5920
Re: Snippet: cwsoft-anynews
« Reply #194 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]]

Offline J.R.

  • Posts: 24
Re: Snippet: cwsoft-anynews
« Reply #195 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);
     }
 
                  





« Last Edit: March 04, 2015, 01:10:49 AM by J.R. »

Offline Gast

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

Offline DarkViper

  • Forum administrator
  • *****
  • Posts: 3062
  • Gender: Female
Re: Snippet: cwsoft-anynews
« Reply #197 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 can be.

Manuela
Der blaue Planet - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen

"You have to take the men as they are… but you can not leave them like that !" :-P
Das tägliche Stoßgebet: Oh Herr, wirf Hirn vom Himmel !

Offline J.R.

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

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: Snippet: cwsoft-anynews
« Reply #199 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
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden