ImpressPages CMS "Hello Widgets" plugin
This is a small example how to add your first widget to ImpressPages CMS 2.x website.
Download this example
- Extract downloaded archive to your website's ip_plugins folder. Folder examples should be a child of ip_plugins folder.
- Log in to administration area, go to tab Developer -> Modules and press install.
- You will see new widget in Content Management tab.
How it is built?
Folder example describes the group of the plugins. Folder hello_widgets is plugin name. These folders (including install / uninstall folders) create basic plugin structure. Read here about ImpressPages CMS plugins.
In this example our focus is on the widget folder inside the plugin. This is the folder where all widgets of that plugin goes. Each folder in widget folder represents one widget. In this example we have only one widget called "IpMyFirstWidget".
All widgets should start with a capital letter. This is important when more functionality is added to the widget.
All widgets should start with the developer prefix. This example is built by ImpressPages team. So, it starts (as all our widgets) with prefix "Ip".
The simplest widget is just an HTML code. So we have two separate folders:
- management/default.php - html that goes as your widget administration tools
- preview/default.php - html that will be visible to website visitors
That's all. If you need some HTML code snippets to be added to your website, you can use this example as a basis.
You can add PHP code to default.php files. Just keep in mind that these files should have no business logic or interactions with database. Just printing some required data. It is not a restriction of ImpressPages CMS. It is the culture of programing using MVC architecture.