Table of Contents

Widget Management

By default in Wizard's Toolkit each user has their own dashboard of widgets. These widgets give them important stats and information regarding the website. Some pre-defined widgets are included with Wizard's Toolkit and any developer with a little SQL knowledge can easily create unlimited custom widgets.

In the back office (located at /admin/ by default), under Client Control you can see both “Widgets” and “Widget Groups”.

First create Widgets and then assign them to Widget Groups.

YouTube Tutorial

Widget Creation

When defining a widget you choose the following:

Note, if you are making a List widget and the list has links for navigation you should not also use “Link to Page” because then both will trigger.

Widget Groups

When defining a widget group you choose the following:

Note that programmatically you can ignore the security level and staff role functionality. You could make it so all users have access to these “Widget Dashboards” quite easily. Ask and I will send demo code.

If the “Use for Personal Dashboard default” checkbox is checked then this widget set will be copied to the user's personal set of widgets the first time they visit the dashboard if they do not already have personal widgets.

wtkWidgetGroup_X_Widget

This data table is used as a many-to-many SQL table to associate wtkWidgets with wtkWidgetGroups.

Data columns include:

If UserUID is NULL then the Widget Group set is considered the Master Set. User's cannot modify this in any way. This can only be managed in the Back Office.

When a dashboard needs to be edited by a user, simply copy the WidgetGroup and fill the wtkWidgetGroup_X_Widget.UserUID value with the wtkUsers.UID value. Then the user will be able to add, delete and re-prioritize widgets for their own dashboard.

Defaulting Widgets to User Dashboard

The logic used to determine if a widget set is copied to a user is as follows:

The “copy” process copies the `wtkWidgetGroup_X_Widget` data for the associated wtkWidgetGroup with NULL UserUID values making the new set contain the wtkUsers.UID in the wtkWidgetGroup_X_Widget.UserUID value.

Use Widgets to Update Data and Refresh Widget

In the WTK Admin website if you have the Widget “Link to Page” and make that page “Use Modal Window”, you can easily allow editing of data and have it update the widget upon saving.

The /wtk/widgets.php page automatically passes `wtkWidgets`.`UID` to the wtkModal JS function which is passed as id parameter. The PHP page you have it call will automatically store that value in the $gloId global variable.

In your PHP page have the update buttons defined as follows:

$pgBtns = wtkModalUpdateBtns('../wtk/lib/Save','widgetRefresh');

Make certain your PHP has the form defined as:

<form id="FwidgetRefresh" method="POST">

Also in your PHP add this code to put the `wtkWidgets`.`UID` into a hidden field.

$pgHtm .= wtkFormHidden('WidgetUID', $gloId);

The “widgetRefresh” is then sent back via the modalSave JS function. That retrieves the hidden WidgetUID value and passes it back via an AJAX call to /wtk/widgets.php. Normally widgets.php returns several widgets but when called this way it receives the UID and returns only the specific Widget requested, updating it on the dashboard.