diff options
author | Mario Vavti <mario@mariovavti.com> | 2017-10-30 10:42:51 +0100 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2017-10-30 10:42:51 +0100 |
commit | b28ff509b1f7c95ac723fb1b2a20929da2ba7d3d (patch) | |
tree | 10cbc640f84ffabe70494822aa19096610fe5ded /doc | |
parent | 1f47f4ff9644523f14898ecd6f55d0fd0438d253 (diff) | |
parent | 4fef29e61c32b129f0090a4962d91607337a9406 (diff) | |
download | volse-hubzilla-b28ff509b1f7c95ac723fb1b2a20929da2ba7d3d.tar.gz volse-hubzilla-b28ff509b1f7c95ac723fb1b2a20929da2ba7d3d.tar.bz2 volse-hubzilla-b28ff509b1f7c95ac723fb1b2a20929da2ba7d3d.zip |
Merge remote-tracking branch 'mike/master' into dev
Diffstat (limited to 'doc')
-rw-r--r-- | doc/Widgets.md | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/doc/Widgets.md b/doc/Widgets.md index 4ad899a0f..7761b1833 100644 --- a/doc/Widgets.md +++ b/doc/Widgets.md @@ -129,14 +129,44 @@ Some/many of these widgets have restrictions which may restrict the type of page Creating New Widgets ==================== -If you want a widget named 'slugfish', create widget/slugfish.php containing +### Class Widgets + +To create a class-based widget named 'slugfish' create a file with the following contents: + +```` +<?php + +namespace Zotlabs\Widget; + + +class Slugfish { + + function widget($args) { + + ... widget code goes here. + ... The function returns a string which is the HTML content of the widget. + ... $args is a named array which is passed any [var] variables from the layout editor + ... For instance [widget=slugfish][var=count]3[/var][/widget] will populate $args with + ... [ 'count' => 3 ] + + } + +```` + +The resultant file may be placed in widget/Slugfish/Slugfish.php , or Zotlabs/SiteWidgets/Slugfish.php . It also may be linked from a git repository using util/add_widget_repo. + + + +Traditional function based widget: + +If you want a widget named 'slugfish', create widget/widget_slugfish.php containing <?php function widget_slugfish($args) { - .. widget code goes here + .. widget code goes here. See above information for class-based widgets for details. } |