Making Widget System #126
taufik-nurrohman
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
A widget is a special feature on a website. Some people may have different terms to describe it such as block, chunk, element, or gadget. You must have ever seen a search box, recent post and recent comment list appear on a website, they are referred to as widgets.
Using the layout API, you can make a widget system.
By creating a file named
widget.php
in the.\lot\layout
folder, then awidget
method will be added automatically to theLayout
class.In a layout file, the
Layout
class can be called viaself
orstatic
reference:In
.\lot\layout\widget.php
file, add the default widget markup. It usually consists of a title and a content:You will have
$title
and$content
variable set via the layout data argument:Automatic and dynamic contents can be created separately as other widgets. You can make it as a specific file stored in
.\lot\layout\widget
folder:And call it this way:
In
.\lot\layout\widget\recent-pages.php
file, process$content
value to be assigned tocontent
parameter in the default widget call:Beta Was this translation helpful? Give feedback.
All reactions