Helpful Information
 
 
Category: vB5 Programming Discussions
Widgets/Modules

Anyone found out how to create widgets yet? I haven't really had much chance to look around and find out how, I imagine it's like a template thats within the widget?

Widgets are a part of products. And there are different types of widgets.

The way I've been creating them is to manually add them into the <widget> section of the product install XML.

In the sample below, a PHP widget would be created with 2 fields. One field is the title for the widget, the other contains PHP Code...

<widget>
<title>New Widget</title>
<template>widget_15</template>
<admintemplate />
<category>Display</category>
<icon>module-icon-php.png</icon>
<cloneable>0</cloneable>
<guid>myproduct-widget_15-UNIQUE_ID_NUMBER_GOES_HERE</guid>
<definitions>
<definition>
<name>title</name>
<label>Title</label>
<field>Text</field>
<isrequired>1</isrequired>
<isusereditable>0</isusereditable>
<displayorder>1</displayorder>
<validationtype>force_datatype</validationtype>
<validationmethod />
<defaultvalue>New Widget</defaultvalue>
</definition>
<definition>
<name>code</name>
<label>PHP Code</label>
<field>LongText</field>
<isrequired>0</isrequired>
<isusereditable>1</isusereditable>
<displayorder>2</displayorder>
<validationtype>force_datatype</validationtype>
<validationmethod />
<defaultvalue>echo 'Hello';</defaultvalue>
</definition>
</definitions>
</widget>


A completely custom widget is done in much the same way, except you specify your own template, etc. and the fields can be whatever you want them to be.

If you have experience of creating widgets for cms, then it will be very easy to create widget/module for vB5.

You can pull fetch_rows (ex: for latest threads) by creating a class in core/vb/api folder and then by using
{vb:data variable_name, classname, function_name, arguments)

Then {vb:each} will be use for printing each row.










privacy (GDPR)