Recent Topics

1 Sep 30, 2011 16:54    

Remembering I'm a real n00b please.

I am editing a copy of an existing plugin - Category List (as a model for my own - easier to start with something that is known to work)

To _coll_category_list.widget.php I have added a new disp param to function get_param_definitions(). This was simple and it works fine. I can edit it in Dashboard making a setting which then is recognised by $this->disp_params[''] in the function display().

I can also change the new parameter in the calling method of index.main.php of the appropriate skin. ie

skin_container(NT_('SubMenu'), array(
		'block_start' 				=> '',
		'block_end' 				=> '',
		'block_display_title' 	=> false,
		'new_param'					=> 'alpha',
		'list_start' 				=> '',
		'list_end' 					=> ''',
		'item_start' 				=> ''',
		'item_selected_start'	=> '',
		'item_end' 					=> '',
		'use_form'					=> true,
	));

Everything OK so far.

BUT...

That param 'use_form' does not seem to take a value of true. So when tested in the _coll_category_list.widget.php it does nothing !

I could probably create a new param and use that as an alternate in the test but this seems clumsy when a param is already supplied.

Or am I missing something ?

2 Sep 30, 2011 19:17

First of all, are you editing a plugin or a widget from /inc/widgets/widgegts/_coll_category_list.widget.php ? It's not the same, you shouldn't work on existing widgets if you want to create a plugin.

Pick a plugin that provides a widget, like the one I released yesterday
http://forums.b2evolution.net/viewtopic.php?t=22919

See how it works, in SkinTag() method you use $params['my_param'] instead of $this->disp_params['my_param']

3 Sep 30, 2011 22:39

Methinks you are confusing me. Taking me out to explore a plugin that is not within scope is just adding to the confusion.

I thought it was a simple question and fairly clear. The editing of widgets/_coll_category_list.widget.php is the simplest way to get where I want to (and the simplest way back should it mess up). I can see no alternative without completely reinventing the wheel. That does not seem to be a good solution.

As indicated I am half way to a solution. The new parameter of my widget works and is visible and editable in Dashboard and the raw php code works withing the widget. So there is nothing wrong with that.

It is simply that one of the parameters used inside the coded function display does not take the value given to it in the skin_container passed params array.

I could easily add more code (another parameter 'working_use_form' perhaps and then test and code accordingly. But this seems to be a total waste of coding and effort when there is a name_parameter and a perfectly valid test already there.

I just do not understand why $this->disp_params['new_param'] works yet $this->disp_params['use_form'] doesn't?

4 Oct 01, 2011 16:46

OK I have got it to do almost what I wanted by adding yet another parameter.
So now back to examining it as a plugin.

sam2kb wrote:

Pick a plugin that provides a widget, like the one I released yesterday
http://forums.b2evolution.net/viewtopic.php?t=22919

See how it works, in SkinTag() method you use $params['my_param'] instead of $this->disp_params['my_param']

That looks essentially what I have done BUT and it is a big but how do I call the display method from index.main.php ?

(This might be a real numbskull question.)

For example I have loaded your widget in Dashboard > Gallery > Global settings ? > Plugin configuration
Then activated it in Dashboard > Blog settings > Widgets under the chosen Skin Block.
Nothing appears on the screen - I have even tried calling it through SkinTag(NT_('SubMenu'), array(...
but that just causes a bad error.

5 Oct 02, 2011 23:10

That plugin is for b2evolution v4.

That looks essentially what I have done BUT and it is a big but how do I call the display method from index.main.php ?

To call a particular widget use this, check a_noskin.php for examples

skin_widget( array(
	// CODE for the widget:
	'widget' => 'my_code',
	// Optional display params:
	'list_start' => '<ul>',
	'list_end' => '</ul>',
	'item_start' => '<li>',
	'item_end' => '</li>',
) );

The above code will only work on stock widgets. If you want to call a widget supplied by your plugin use this instead

// Call the coll_common_links widget:
$Plugins->call_by_code( 'my_code', array(
	// Optional display params:
	'list_start' => '<ul>',
	'list_end' => '</ul>',
	'item_start' => '<li>',
	'item_end' => '</li>',
) );


Form is loading...