############################################################################################################ Widget visibility hack for b2evolution 2.4.1. This hack adds the function to hide or show a single widget. Patch in the root directory (the directory which holds the folders "inc", "conf" etc.). The command you would use under Linux (and perhaps other operating systems) is: patch -p1 < path/to/this/file Now modify your b2evolution database. Execute the following SQL command: ALTER TABLE `evo_widget` ADD `wi_show` BOOL NOT NULL DEFAULT '1' COMMENT 'visibility hack' AFTER `wi_order`; Have fun. ############################################################################################################ diff -ru c1/inc/skins/model/_skin.class.php c2/inc/skins/model/_skin.class.php --- c1/inc/skins/model/_skin.class.php 2008-03-16 17:23:08.000000000 +0100 +++ c2/inc/skins/model/_skin.class.php 2008-03-19 00:18:40.000000000 +0100 @@ -164,6 +164,9 @@ { foreach( $Widget_array as $ComponentWidget ) { + // visibility hack + // skip this widget if it's hidden + if (!$ComponentWidget->get('show')) continue; // Let the Widget display itself (with contextual params): $ComponentWidget->display( $params ); } @@ -428,4 +431,4 @@ -?> \ Kein Zeilenumbruch am Dateiende. +?> diff -ru c1/inc/widgets/model/_widget.class.php c2/inc/widgets/model/_widget.class.php --- c1/inc/widgets/model/_widget.class.php 2008-03-16 17:23:08.000000000 +0100 +++ c2/inc/widgets/model/_widget.class.php 2008-03-19 00:18:40.000000000 +0100 @@ -40,6 +40,8 @@ */ var $sco_name; var $order; + // visibility hack + var $show; /** * @var string Type of the plugin ("core" or "plugin") */ @@ -92,6 +94,8 @@ $this->code = $db_row->wi_code; $this->params = $db_row->wi_params; $this->order = $db_row->wi_order; + // visibility hack + $this->show = $db_row->wi_show; } } @@ -723,4 +727,4 @@ -?> \ Kein Zeilenumbruch am Dateiende. +?> diff -ru c1/inc/widgets/views/_widget_list.view.php c2/inc/widgets/views/_widget_list.view.php --- c1/inc/widgets/views/_widget_list.view.php 2008-03-16 17:23:08.000000000 +0100 +++ c2/inc/widgets/views/_widget_list.view.php 2008-03-19 00:18:40.000000000 +0100 @@ -104,6 +104,11 @@ { // The name is customized and the short desc may be relevant additional info $widget_name .= ' ('.$ComponentWidget->get_short_desc().')'; } + // visibility hack + if (!$ComponentWidget->get('show')) // widget is hidden... + { + $widget_name .= ' ['.T_('Hidden').']'; // ...so let's show this in the widget title. + } echo ''.$widget_name.''; $Table->display_col_end(); @@ -135,6 +140,8 @@ // Actions $Table->display_col_start(); + // visibility hack + echo $ComponentWidget->get('show') ? action_icon( T_('Hide this widget!'), 'deactivate', regenerate_url( 'blog', 'action=toggle&wi_ID='.$ComponentWidget->ID )) : action_icon( T_('Show this widget!'), 'activate', regenerate_url( 'blog', 'action=toggle&wi_ID='.$ComponentWidget->ID )); echo action_icon( T_('Edit widget settings!'), 'edit', regenerate_url( 'blog', 'action=edit&wi_ID='.$ComponentWidget->ID ) ); echo action_icon( T_('Remove this widget!'), 'delete', regenerate_url( 'blog', 'action=delete&wi_ID='.$ComponentWidget->ID ) ); $Table->display_col_end(); @@ -173,4 +180,4 @@ echo ''; -?> \ Kein Zeilenumbruch am Dateiende. +?> diff -ru c1/inc/widgets/widgets.ctrl.php c2/inc/widgets/widgets.ctrl.php --- c1/inc/widgets/widgets.ctrl.php 2008-03-16 17:23:08.000000000 +0100 +++ c2/inc/widgets/widgets.ctrl.php 2008-03-19 00:18:41.000000000 +0100 @@ -53,6 +53,8 @@ case 'delete': case 'move_up': case 'move_down': + // visibility hack + case 'toggle': param( 'wi_ID', 'integer', true ); $WidgetCache = & get_Cache( 'WidgetCache' ); $edited_ComponentWidget = & $WidgetCache->get_by_ID( $wi_ID ); @@ -126,6 +128,8 @@ $edited_ComponentWidget->set( 'coll_ID', $Blog->ID ); $edited_ComponentWidget->set( 'sco_name', $container ); + // visibility hack + $edited_ComponentWidget->set('show', 1); // INSERT INTO DB: $edited_ComponentWidget->dbinsert(); @@ -229,6 +233,22 @@ case 'list': break; + // visibility hack + case 'toggle': + if ($edited_ComponentWidget->get('show') == 1) + { + $Messages->add(T_('Widget has been hidden'), 'success'); + $edited_ComponentWidget->set('show', 0); + } + else + { + $Messages->add(T_('Widget has been shown'), 'success'); + $edited_ComponentWidget->set('show', 1); + } + $edited_ComponentWidget->dbupdate(); + $action = 'list'; + break; + default: debug_die( 'Action: unhandled action' ); } @@ -303,4 +323,4 @@ -?> \ Kein Zeilenumbruch am Dateiende. +?>