What is the correct way to implement a MVC structure in Joomla 3 helpers? In example I generate a html part through helper function like following:

class TestHelpersView {

    function demo($params = array()) {
        // prepeare something 

        $url = '#';
        $text = 'Unlink';
        $attribs = array('onclick'=>"foo();");

        // compose some html
        $html = '<b>'.JHtml::link('#', $text, $attribs).'</b>';

        return $html;

In different views I call:

echo TestHelpersView::demo();

It it possible and useful to use a MVC structure to compose the helper html result?

1 Answer 1


Joomla has a default MVC structure, there is no need to add a new level through helpers to generate an output.

Alternatively, Joomla calls you component simply including the main php file, yourcomponent.php. Thus, you can implement any PHP script inside your component, using any part of the Joomla CMS (or not). In this space, you can implement your own MVC.

For instance, FOF is a library to develop extensions based on a different MVC structure, smoothly integrated with Joomla classes: https://github.com/akeeba/fof or https://www.akeebabackup.com/documentation/fof.html .

  • So it is no good practice to generate a bigger part of view by echo a helper function which returns html code? If not how do I reuse view parts in different views, using include?
    – frthjf
    Nov 25, 2014 at 9:53
  • Views and Layours can be overriden, but not the structural part of a component. If you want to override the component... just create a new component.
    – Anibal
    Nov 25, 2014 at 18:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.