Recent Topics

1 Dec 24, 2007 02:28    

I'm trying to create a widget for a G2 image block for my blog and want to be able to customize the widget for various items to display. After going through some documents, I found that I can use a multiple selection list in the backoffice in the widget properties and seems to initially work correctly (it outputs the selections into an array). However, if I go back to the widget properties, I get the following error, and the widget will no longer remember my earlier settings. Here is some sample code that generates the error:


function get_widget_param_definitions( $params )
{
     $r = array(
          'iblock' => array(
		'label' => 'Choose Image Block',
		'note' => T_('Display which type of image block to display; Default: Random Image'),
		'type' => 'select',
		'options' => array( 'randomImage' => T_('Random Image'), 'recentImage' => T_('Recent Image'), 'randomAlbum' => T_('Random Album'), 'recentAlbum' => T_('Recent Album') ),
		'defaultvalue' => 'randomImage',
		'multiple' => true
	   ),
     );
return $r;
}

I get the following error:

Notice: Array to string conversion in /home/username/public_html/testblog/inc/_core/ui/forms/_form.class.php on line 1783

Any help would be appreciated. Thanks.

2 Dec 26, 2007 13:25

Crack open inc/_core/ui/forms/_form.class.php and meander down to 1780 (ish ) and change the existing code to look like this and see if it solves things for you :

			if(
					( is_array( $field_value ) && in_array( $l_value, $field_value ) ) ||
					( !is_array( $field_value ) && (string)$l_value == (string)$field_value ) // cast to string so "1,2" is != 1
				)
			{
				$options_list .= ' selected="selected"';
			}

¥

3 Dec 26, 2007 17:55

That fixed the problem. Thanks.

4 Dec 26, 2007 19:23

cool :D

committed to cvs

¥

5 Dec 28, 2007 22:09

hemeac,

When you were working with the widget stuff, did you find a way to manually call a widget by itself instead of having to call the entire set of widget in the sidebar?

For example, I just want to call the "Linkblog" widget, not the entire set of widgets on the sidebar.

Edgar.

6 Jan 18, 2008 04:48

Has anybody had a chance to review this qusetion?

How can one call a single widget via php code from the index.main.php file?

I don't want the entire set of "side bar" widgets. I just want the "Comments" and LinkBlog"

7 Jan 18, 2008 05:14

Hi Edgar,

You still need a container, even if it occupies only one widget.

Good luck

8 Jan 18, 2008 05:40

Afwas wrote:

... You still need a container, even if it occupies only one widget. ...

Actually that's technically not true. I've lost the code for it by choice, but calling a single widget without a container is very possible. When I figure it out I was like "it's that easy???", but this does NOT mean losing containers is a good idea.

OTOH if I want to add something totally unique, like PHP code in the middle of my sidebar for example, I would have to split my sidebar into two containers then add my extra code between the container calls. Not the worst fate in the world, but not very elegant if you ask me. The 'old way', in this situation, was much cleaner.

The drawback to calling individual widgets is that ALL widgets will have to be called that way. Plus what you do is turn your back on the future direction of the core software, and what's the point of that?

Sorry for the OT reply, but "technically speaking you don't need containers" is a true statement.

9 Jan 18, 2008 06:13

Never mind being OT.
A widget is technically speaking a plugin so you might get away without a container. Might come in handysome day. But it's sooo easy simply copy a container, rename the constructor variable and done.

10 Jan 19, 2008 14:53

/**
 * Template tag. Display a Widget.
 *
 * This load the widget class, instantiates it, and displays it.
 *
 * @param array
 */
function skin_widget( $params )

;)

¥


Form is loading...