Recent Topics

Widget instance limit

Started by on Mar 14, 2012 – Contents updated: Mar 14, 2012

Mar 14, 2012 03:01    

Is there a way to limit # of widget instances, like there is on plugins ? $number_of_installs

kinda OT: How to use widget id in widget name field. ( to avoid conflict of the same instances of the widget coming from the same plugin.

Mar 16, 2012 14:21

There's no easy way. If you really need to limit it, run this query to find out the total number of instances installed, and fire an error.


$x $DB->get_var('SELECT COUNT(*) wi_ID FROM T_widgets WHERE wi_code = "my-widget-code"');
if( $x )
    $this->msg('Stop adding this widget!''error');

The problem is that there's no plugin event to hook up to in b2evo v4. It's only available in b2evo 5 :( So you may have to run this code in SessionLoaded and only on widget add request in backoffice.

Mar 17, 2012 00:36

sounds like this v5 is going to be very flexible (:

Form is loading...

Secure CMS – This forum is powered by b2evolution CMS, a complete engine for your website.