Search code examples
mysqljoomlajoomla-extensions

Joomla creating and calling multiple views


I'm a wordpress developer trying out a Joomla component build.

My issue is, I'm trying to understand how to incorporate multiple views within a component.

For example, producing a list of entries in one view, and then when one of those entries is selected forwarding to another view that produces a single entry.

I understand php enough to know how to get the hyperlinks done dynamically, but I don't know how to declare the two separate views in Joomla. Will each view require it's own model? (I assume not.) Does any of that make sense?

Like I said, Joomla newb, any links or references are greatly appreciated.


Solution

  • Firstly, each view should have it's own model. As for forwarding to another view, this should be done in the controller, however should be done with 2 separate views. Once the task has been performed, set it to redirect like so:

    function your_function(){
        $msg = JText::_( 'Operation Successful' );
        $this->setRedirect( 'index.php?option=com_hellowworld&view=hellowworldview', $msg );
    }
    

    Obviously you will need to change "com_hellowworld" to the name of your component and "hellowworldview" to the name of the view you want to redirect to.

    Have a look through the documentation for Developing an MVC Component for Joomla 2.5. It will guide you through in detail, all the basics of developing your component.

    Hope this helps.