How to create dashboard widgets in Newscoop
Newscoop's dashboard is one of the most important views for an editor in the newsroom, so lets create some widgets for it. Widgets are standalone pieces of UI; the application will just manage them and render.
Where do widgets live? By default every widget is placed in:
newscoop/extensions/{widget-directory}
So, let's create our first widget.
And that's it! Your widget will be available on the widgets list. But this is not everything that widgets can do. Widgets have metadata, metadata can be set with annotations for class...
Widgets can be set with property or even from .ini file (file must be inside widget directory and have this same name as directory). For example...
Another great feature from widgets is "settings" module. Settings are per user and per widget. They are saved in the database as json string. Create first own settings...
Setting property must have special two annotations: @setting and @label (with label text for setting).
Settings are accessible with magic getter function - for example $author will have $this->getAuthor() method. Simple!
There are a already few interesting widgets by default in Newscoop, for example: Sourcefabric.org news reader, wikipedia search, or last images in Newscoop Media Archive.
Happy widgeting! Any questions? Ask me in the comments!
--
This post first appeared on my blog. Check out my Github profile!