Combining views in one page

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
User avatar
RustyJoomla
Joomla! Explorer
Joomla! Explorer
Posts: 409
Joined: Wed Aug 01, 2007 12:08 am
Location: UK
Contact:

Combining views in one page

Post by RustyJoomla » Mon Jun 30, 2014 12:20 pm

Hi All,

I am developing a competition component using Component Creator.

I have got two tables in the DB:

#__competition_data
#__competition_entries

#__competition_data contains competition questions (with a frontend list and item view)
#__competition_entries contains information from each user submitting answers (with a frontend form view and a backend list view)

I have created an Empty View using Component Creator and I want to able to view a mixture of the above in a frontend view.

Competition Question data
Competition Entry Form

I know I need to edit the /models/frontendv1ewform.php and /views/frontendv1ewform/view.html.php to get the data to display, but I can't work out where I'm going wrong.

Any help please?

Thanks
Follow me on Twitter - http://twitter.com/RustyJoomla
Company Joomla Website - https://storm.agency

User avatar
Perino
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Fri Nov 01, 2013 4:52 pm

Re: Combining views in one page

Post by Perino » Tue Jul 01, 2014 3:26 pm

You can call each necessary model from the controller, or direct from the view.html.php to get your data. With all the information of the different models, you can display a mixture in your frontend view.

User avatar
RustyJoomla
Joomla! Explorer
Joomla! Explorer
Posts: 409
Joined: Wed Aug 01, 2007 12:08 am
Location: UK
Contact:

Re: Combining views in one page

Post by RustyJoomla » Tue Jul 01, 2014 3:33 pm

Thanks for your reply. This is the part I'm getting stuck with. Any help with this please?
Follow me on Twitter - http://twitter.com/RustyJoomla
Company Joomla Website - https://storm.agency

User avatar
Perino
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Fri Nov 01, 2013 4:52 pm

Re: Combining views in one page

Post by Perino » Tue Jul 01, 2014 4:00 pm

According to the Joomla MVC schema you have to do that in the Master Controller. I prefer the more convenient way and do it direct in the view.html.php file.

In this case you only need to make an instance of your model ( JModelLegacy::getInstance) to access your data => for detailed information see http://api.joomla.org/cms-3/classes/JModelLegacy.html

User avatar
RustyJoomla
Joomla! Explorer
Joomla! Explorer
Posts: 409
Joined: Wed Aug 01, 2007 12:08 am
Location: UK
Contact:

Re: Combining views in one page

Post by RustyJoomla » Fri Aug 22, 2014 9:33 am

Thanks for your reply. So from what you're saying I need to implement the following:

getInstance(string $type, string $prefix = '', array $config = array()) : mixed

But I don't understand what I need to put in the above code?
Follow me on Twitter - http://twitter.com/RustyJoomla
Company Joomla Website - https://storm.agency


Locked

Return to “Joomla! 3.x Coding”