How to create a simple widget


  1. New Widget

What are widgets? Read this.

Inside Gentics Portal.Node PHP widgets can be only created inside the folder modules.

1 New Widget

Before creating a widget you need to create a module for it.

Then create a PHP-file <portal>/common/modules/post/widgets/TestWidget.php with the following content:

class TestWidget extends BaseWidget {
    public function run()  {

All widgets inside Gentics Portal.Node PHP must inherit from BaseWidget class. It contains basic logic for working.

Then we need a view for this widget.

Create PHP-file <portal>/common/modules/post/widgets/views/TestWidget.php with every PHP or HTML-content you like.

The new widget can be used in any CMS page (but it will only be rendered after publishing of CMS)

<?php $this->widget('test.widgets.TestWidget'); ?>

More about views you can read here