Hello could someone help me fix a little piece of helper.php code which is linked to a Joomla module .xml file.

Basically I have a module for displaying articles with different corner styles. There are 4 style options which can be set for each module via the backend administrator -squared, rounded, roundedfixed, disabled. The 4 options are currently selected by using radio buttons set to - 'enable' or 'disable'.

Instead of using radio buttons, I really want to use a drop-down list box displaying the style options.

I began with this xml code to display the radio buttons -

<param name="firstrounded" type="radio" label="FIRSTROUNDED" description="">
<option value="0">DISABLED</option>
<option value="1">ENABLED</option>
</param>

<param name="firstsquaredcorners" type="radio" label="FIRSTSQUAREDCORNERS" description="">
<option value="0">DISABLED</option>
<option value="1">ENABLED</option>
</param> 

<param name="firstroundedfixed" type="radio" label="FIRSTROUNDEDFIXED" description="">
<option value="0">DISABLED</option>
<option value="1">ENABLED</option>
</param>

And this php code from my helper.php file -

$this->corners[0]['rounded'] = $params->get('firstrounded', 1); 
$this->corners[0]['squared'] = $params->get('firstsquaredcorners', 1); 
$this->corners[0]['fixed'] = $params->get('firstroundedfixed', 1);  

I then changed the xml code to display a drop down listbox instead of the radio buttons...

<param name="firstcorners" type="list" label="FIRSTCORNERS" description="">
<option value="squared">squared</option>
<option value="rounded">rounded</option>
<option value="roundedfixed">roundedfixed</option>
<option value="cornersdisabled">cornersdisabled</option>
</param>

..I am unsure how to alter the php code to match the new .xml drop-down list box code. I need 4 options, sqaured, rounded, rounded fixed and cornersdisabled.

Can anyone help me out?

    What's the second argument to the get() method for? I'll leave it as 1...

    $legitimate_values = array('squared,'rounded','roundedfixed',cornersdisabled');
    
    $this->corners[0]['squared']=false;
    $this->corners[0]['rounded']=false;
    $this->corners[0]['roundedfixed']=false;
    $this->corners[0]['cornersdisabled']=false;
    
    $corner = $params->get('firstcorners', 1);
    if(in_array($legitimate_values,$corner))
    {
        $this->corners[0][$corner] = true;
    }
    

      Thankyou for your reply.

      Im getting the following message with your code - "Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/fhlinux128............./helper.php on line 161"

      Which is this line -

      if(in_array($legitimate_values,$corner))

      Any ideas what may be causing it?

      Im really hopeless with php and the Get method seems to be used all over joomla php code, im sorry I dont know what it is used for.:queasy:

        tomkilbourn wrote:

        Any ideas what may be causing it?

        Yes, according to [man]in_array[/man] I got the arguments back to front. Note there is also an (obvious) typo in the first line of what I wrote.

        For the rest of the day I'm going to concentrate on writing in one language at a time.

          Weedpacket;10937011 wrote:

          For the rest of the day I'm going to concentrate on writing in one language at a time.

          klingon?

            Weedpacket;10937011 wrote:

            Yes, according to [man]in_array[/man] I got the arguments back to front. Note there is also an (obvious) typo in the first line of what I wrote.

            For the rest of the day I'm going to concentrate on writing in one language at a time.

            I picked up the typo but how do Im not sure how to fix the arguments back to front. Im really am a novice here 🙂

              since there's 2 and they are 'back to front' how about swapping them?

                Do you mean swap the line -

                if(in_array($legitimate_values,$corner))

                for -

                if(in_array($corner,$legitimate_values))

                If so, Ive tried that already and am still getting the same message.

                  I have got it to work 🙂

                  $corner = array('squared','rounded','fixed');
                  $this->corners[0]['squared']=false;
                  $this->corners[0]['rounded']=false;
                  $this->corners[0]['fixed']=false;
                  
                  $legitimate_values = $params->get('firstcorners', 1);
                  if(in_array($legitimate_values,$corner))
                  {
                      $this->corners[0][$legitimate_values] = true;
                  } 

                  Thankyou everyone for your help and replies, much appreciated 🙂

                    You might want to swap the names of $corner and $legitimate_values, though, so that they're meaningful:

                    $legitimate_values = array('squared','rounded','fixed');
                    $this->corners[0]['squared']=false;
                    $this->corners[0]['rounded']=false;
                    $this->corners[0]['fixed']=false;
                    
                    $corner = $params->get('firstcorners', 1);
                    if(in_array($corner,$legitimate_values))
                    {
                        $this->corners[0][$corner] = true;
                    } 
                      Write a Reply...