Skip to main content

SkaDate / Oxwall : How to create simple widget in Skadate X / Oxwall ?

What is widget in Skadate / Oxwall ?

Widgets are an essential part of the web software. You can call widgets as an extension block of that software or the theme. In Skadate / Oxwall widgets are components that can be attached to the widget panels. Lets dig little deep into Skadate / Oxwall widgets.

 

Skadate / Oxwall available Widget Panels

There are three panels in Skadate / Oxwall which currently used for widgets to attached with.

  1. Index page
  2. Dashboard
  3. Profile page

Here in our example we will create a Custom status widget, which will be used in Dashboard panel. You can use one widgets to all panel there are no limits.

 

Custom Status Widget

Create a php file under root/ow_system_plugins/base/components named it to custom_status_widget.php

Now create a class and its construct method as shown below

The widget class has to be always extended by “BASE_CLASS_Widget”. Now lets add few more setting methods to display and fetch our desired content in widget.

Add Setting method

Above method will redefine default setting method of extended class and by using this method you can add more settings to the widgets setting area,  we are adding a textarea for our status widgets where we can add our status words.

Standard Setting Method

This method will redefine the standard settings method. You can able to update or set default values of widgets setting by using this method. Here we are updating Widgets Title as ‘Custom Status Update’.

Access Method

This method works as it said. By using this method you can manage the visibilities of particular widgets. We are using ACCESS_ALL constant which give full visibility to the widgets means both guest and logged in users can see this widgets in front end.

Render Method

This is standard method of all components which called before rendering.

Covering all code together, here is widget Class file.

Widgets View file

After this component class we need to add a View file to render the content which we have developed in status component.

Lets create a view file under

root/ow_system_plugins/base/views/components/ and named it to custom_status_widget.html

Make sure you use the standard name formatting of Skadate / Oxwall for components and view files.

Now add following code in View html file to show the content.

Our widget is almost ready but still we need to attaché it to the panel, lets attaché this widgets to Dashboard panel as status always comes on Dashboard.

Register the widget

The first parameter is the name of the widget class. The second parameter stands for whether the widget can be cloned, or may have only one sample on the page

Now lets Add the widget to the page

Choose a special position on the page to add the widget. The third parameter of this function is the widget’s position in a certain section. If you want to add the widget to the very bottom, you should set -1.

warping three line together

Widget view backend/Frontend

You can see our attached widgets in Admin Dashboard section,

Custome status widgets

you also have the ability to add different widgets predefined settings.

widget setting page

At front end you will see the effective changes also at Site Dashboard section.

Skadate Oxwall front widget panel

Deleting a widget

By using above script in oxwall you can remove the widget and all its samples from all pages.

Conclusion

Skadate / Oxwall widget works as components, you can find more about sections and widgets places at Oxwall’s Blog.

 

Hardik Joshi

Hardik Joshi is Founder, Developer and Writer at eCodezone.com, He loves to write usable code for the Web and other digital sources.