Base class for widgets
This is the code documentation for the SproutCMS project
Search documentation |
class WidgetBase class for widgets
Extending this class<?php
/**
* New class description goes here
*
* @author Your Name, 2026-09-16
**/
class NewClassName extends Widget {
/**
* This function should return the content of the widget settings form.
* The content should be returned as well-formed HTML.
* The content will be contained within a DIV element, which is inside a FORM element.
*
* This function will be called from an AJAX request, so {@see Needs} cannot be used.
* Inline CSS and Javascript should be loaded correctly by the jQuery library.
*
* Form fields *must* be generated using the {@see Form} helper, to ensure correct field
* prefix as well as reloading of field values
**/
public function getSettingsForm () {
// Method code goes here
}
/**
* Run after import of settings, allows extending widgets to clean up settings which may
* have bad values for some reason
**/
public function cleanupSettings () {
// Method code goes here
}
/**
* This function should return the content of the widget that is used on the front-end of the website.
* The content should be returned as well-formed HTML.
* The content will be contained within a DIV element,
* which has the class 'widget', and the class 'widget-[WIDGETNAME]' applied to it.
*
* Styles and Javascript can be loaded with the {@see needs} helper, usually the {@see Needs::fileGroup} function is most useful.
**/
public function render (int $orientation) {
// Method code goes here
}
/**
* This function should return a summary of what this widget's *content* is.
* Don't specify the widget name; we already know that!
*
* Most widgets show content using a category selection box; in that case
* the most useful thing is probably the category name, perhaps also the
* order and limit.
*
* Return NULL if there isn't an appropriate label to use.
**/
public function getInfoLabels () {
// Method code goes here
}
/**
* Is there sufficent content to add this addon at the moment?
* If this widget is not available, a string message should be returned
* If this widget *is* available, NULL should be returned.
**/
public function getNotAvailableReason () {
// Method code goes here
}
/**
* This function should return a URL which can be used to edit the *content* which is
* displayed by this widget.
*
* Most widgets show content using a category selection box; the URL should in that
* case direct the user to the contents list for that category.
*
* Return NULL if there isn't an appropriate URL to use.
**/
public function getEditUrl () {
// Method code goes here
}
/**
* Returns the title to use for the widget - should not contain HTML
**/
public function getTitle () {
// Method code goes here
}
/**
* Set widget title
**/
public function setTitle (string $str) {
// Method code goes here
}
/**
* Gets the english name of this widget
**/
public function getFriendlyDesc () {
// Method code goes here
}
/**
* Gets the english name of this widget
**/
public function getFriendlyName () {
// Method code goes here
}
/**
* Imports the settings
**/
public function importSettings (array $settings) {
// Method code goes here
}
/**
* Return the currently loaded settings for the widget
**/
public function getSettings () {
// Method code goes here
}
}
?>
|
| Powered by Pelzini, version 0.9.0 |
Documentation is made available under the
GNU Free Documentation License 1.2. Generated: Tuesday, 15th September, 2026 at 10:26 am |
|