Line break for radio buttons in joomla 2.5 plugin

149 views
Skip to first unread message

leadersh...@gmail.com

unread,
Jul 6, 2013, 9:53:45 AM7/6/13
to joomla-de...@googlegroups.com
Hi,

I have developed a plugin in Joomla 2.5 and Joomla 3.1, I have Provided some radio buttons for choosing certain parameter.

Below is the snippet of XML file :


<field name="button_style" type="radio" default="style_1" label="Button Style" description="">

<option value="style_1"><![CDATA[<img src="http://URL/facebook.gif" style="vertical-align:middle"/> <br/><br/>
]]></option>

<option value="style_2"><![CDATA[ <img src="https://URL/gtc-like-tweet-pinit.gif"/><br/><br/>]]></option>

On back-endpage of this plugin observed that ; the radio buttons appearing on same line in Joomla 2.5, but for Joomla 3.1 it's ok

Franz

unread,
Jul 8, 2013, 8:28:48 AM7/8/13
to joomla-de...@googlegroups.com
A possible fix for 2.5 is to wrap the options in a <fieldset class="radio">...</fieldset> element.

leadersh...@gmail.com

unread,
Jul 10, 2013, 10:22:15 PM7/10/13
to joomla-de...@googlegroups.com
Thank you for your answer, it's really kind to take the time to write an answer, but unfortunately it didn't work for both Joomla 2.5 and Joomla 3.0 here is the updated code according to your advice


            <field name="button_style" type="radio" default="style_1" label="Button Style" description="">
           
                <fieldset class="radio">
                    <option value="style_1"><![CDATA[<img src="http://cache.addthiscdn.com/icons/v1/thumbs/menu.gif" style="vertical-align:middle"/><br/><br/>
                    ]]></option>
                  </fieldset>
               
                <fieldset class="radio">
                    <option value="style_2"><![CDATA[ <img src="https://cache.addthiscdn.com/www/20130225205628/images/gtc-like-tweet-pinit.gif"/><br/><br/>]]></option>
                </fieldset>

Franz

unread,
Jul 11, 2013, 8:03:12 AM7/11/13
to joomla-de...@googlegroups.com
Sorry, I posted an approximate solution. The full code uses JVersion to print out that <fieldset> ONLY for Joomla 2.5. Here it is:

        if (version_compare(JVERSION, '3.0.0', 'lt')) // Only less than J3, i.e. J2.5 and previous
        {
            return '<fieldset class="radio">' . implode('<br style="clear: left"/>', $options) . '</fieldset>';
        }
        else
        {
            return implode("<br />", $options);
        }

This is production code, so it should work fine :-)

leadersh...@gmail.com

unread,
Jul 11, 2013, 8:35:30 AM7/11/13
to joomla-de...@googlegroups.com
Thank you one more time, but you know the code of the back-end  of the plugin is written inside the xml file so I think that I can't use php there, correct me if I'm wrong :)

Franz

unread,
Jul 12, 2013, 8:29:25 AM7/12/13
to joomla-de...@googlegroups.com
Sorry, I finally realized that I completely mis-read your original post. Of course you cannot add PHP in the XML file. I was thinking of a custom field type. but you are talking about the standard "radio" type. Please ignore my previous posts.
Reply all
Reply to author
Forward
0 new messages