Snippet: cwsoft-anynews

Stefek

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

J.R.

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.

Stefek

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

J.R.

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

DarkViper

Quote from: J.R. on March 04, 2015, 01:02:37 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
[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]

Gast

feel free to do, what ever you want.
we show a working solution  if you take it, it works

J.R.

#196
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);
    }

                  






Gast

the function getNewsItems() needs a config-array or it works with the basic setting (see include.php of the module)

your first code like
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

<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

[[getNewsItems?group_id=1&display_mode=1]]

Gast


J.R.

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



cwsoft

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

cwsoft

Hi,

just use the code shown in example section at GitHub should do the trick.

So instead of:

<?php
if (function_exists('getNewsItems')) {
    echo 
getNewsItems(
        
$group_id 1,
        
$display_mode 1);
}
?>



just use:

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

dbs

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.

[url="https://onkel-franky.de"]https://onkel-franky.de[/url]

J.R.

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.

cwsoft

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

Roych

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

DarkViper

Quote from: cwsoft on October 14, 2014, 09:15:15 PM
QuoteSlovenian 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
[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]

Gast

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

Roych

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

cwsoft

Hi Roych,

Quote from: Roych on October 13, 2014, 02:38:53 PM
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

Roych

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

cwsoft

@Roych: Pushed the Slovenian Anynews language file to my GitHub repo.

Cheers cwsoft


cwsoft

@Roych: Thanks a lot for your Slovenian translation. Will include it with the next cwsoft-anynews version. Highly appreciated.

Cheers cwsoft

Roych

Here is a Slovenian (not Slovakia) translation ;)  SI.php

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

cwsoft

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