Mecha CMS

Mecha CMS blog and documentation.

Class Widget

Updated: Sunday, 07 August 2016

The available widgets.

You can see the examples of this class implementation in the lot\shields\normal\sidebar.php or in the engine\kernel\widget.php file.

Widget Manager

Widget Manager Menu

echo Widget::manager('MENU');

Filters that will affect this widget:

  • widget
  • widget:manager
  • widget:manager.menu
  • url
  • manager:trunk
  • manager:branch
  • manager:twig
  • manager:url

Related: Manager Hooks

Widget Manager Bar

echo Widget::manager('BAR');

Filters that will affect this widget:

  • widget
  • widget:manager
  • widget:manager.bar
  • url

Related: Manager Hooks

Widget Archive

Widget Archive Hierarchy

echo Widget::archive('HIERARCHY');

Filters that will affect this widget:

  • widget
  • widget:archive
  • widget:archive.hierarchy
  • url
  • archive:url

Widget Archive List

echo Widget::archive('LIST');

Filters that will affect this widget:

  • widget
  • widget:archive
  • widget:archive.list
  • url
  • archive:url

Widget Archive Dropdown

echo Widget::archive('DROPDOWN');

Filters that will affect this widget:

  • widget
  • widget:archive
  • widget:archive.dropdown
  • url
  • archive:url

Widget Tag

Widget Tag List

echo Widget::tag('LIST');

Filters that will affect this widget:

  • widget
  • widget:tag
  • widget:tag.list
  • id
  • name
  • slug
  • description
  • url
  • tag:id
  • tag:name
  • tag:slug
  • tag:description
  • tag:url

Widget Tag Cloud

echo Widget::tag('CLOUD');

Filters that will affect this widget:

  • widget
  • widget:tag
  • widget:tag.cloud
  • id
  • name
  • slug
  • description
  • url
  • tag:id
  • tag:name
  • tag:slug
  • tag:description
  • tag:url

Widget Tag Dropdown

echo Widget::tag('DROPDOWN');

Filters that will affect this widget:

  • widget
  • widget:tag
  • widget:tag.dropdown
  • id
  • name
  • slug
  • description
  • url
  • tag:id
  • tag:name
  • tag:slug
  • tag:description
  • tag:url

Widget Search Form

echo Widget::search('search query...', 'Submit');

Filters that will affect this widget:

  • widget
  • widget:search
  • widget:search.form
  • url
  • search:url

Widget Post

Widget Recent Post

echo Widget::recentPost(5);

Filters that will affect this widget:

  • widget
  • widget:recent
  • widget:recent.post
  • widget:recent.article
  • title
  • slug
  • url
  • article:title
  • article:slug
  • article:url

Widget Random Post

echo Widget::randomPost(5);

Filters that will affect this widget:

  • widget
  • widget:random
  • widget:random.post
  • widget:random.article
  • title
  • slug
  • url
  • article:title
  • article:slug
  • article:url

Widget Related Post

echo Widget::relatedPost(5);

Filters that will affect this widget:

  • widget
  • widget:related
  • widget:related.post
  • widget:related.article
  • title
  • slug
  • url
  • article:title
  • article:slug
  • article:url

Widget Response

Widget Recent Response

echo Widget::recentResponse(5);

Filters that will affect this widget:

  • widget
  • widget:recent
  • widget:recent.response
  • widget:recent.comment
  • id
  • time
  • date
  • name
  • email
  • url
  • message
  • permalink
  • comment:id
  • comment:time
  • comment:date
  • comment:name
  • comment:email
  • comment:url
  • comment:message
  • comment:permalink

Creating Your Own Widget

In your functions.php, write something like this to create your own widget:

Widget::add('myTest', function($a, $b, $c) {
    return 'Test widget.';
});

Then, call your custom widget like this in sidebar.php:

echo Widget::myTest($a, $b, $c);

The custom widget above should outputs “Test widget.”.

Filters that will affect your custom widget:

  • widget
  • widget:custom
  • widget:custom.myTest
  • widget:custom.my_test
Donation and Email Subscription