How to create widget system in php(xenForo, Zend framework)

495 views Asked by At

I would like to ask which is the best way to build a widget system with PHP for own cms Addon(xenforo zend framework).

For now I plan following steps:

  • At first I would like to have a directory "widgets" where I can put all widgets.
  • Each widget will habe a file "widgetIndex.php" where the HTML code of the widget will be generated (for Example function "generateHTML").

    class myWidgetName{ function generateHTML(){ return the html of the widget; } }

  • When I build the View, the System will include the widget file

    include(myWidgetName/widgetIndex.php);

and get the html from the function. And this for all widgets.

foreach(widgets_found as widget)
 {
    include widget."/".widgetIndex.php;
    $myWidgetHtmlArray .= generateHTML();
 }

Is this a good Idea or there is a better solution to realize that?

Best regards Tony

0

There are 0 answers