Multiple models - no data retrieved

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
Hamlet55
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Fri Aug 02, 2013 9:27 am

Multiple models - no data retrieved

Post by Hamlet55 » Tue Aug 19, 2014 3:21 pm

Hi!

I am trying to use multiple models in my view. My view is a single items and the models are lists displayed within the view using tabs.

in my controller I added the setModel in the display function

Code: Select all

class ComplianceControllerCompliance extends JControllerForm
{
    public function display( $cachable = false, $urlparam = array() )
   {		
        $view = $this->getView( 'myview', 'html' );
        $view->setModel( $this->getModel( 'mymodel' ), true );		
        $view->setModel( $this->getModel( 'content' ) );
			
        $view->display();
    }
In my view I try to access the needed information like this

Code: Select all

$this->content_items		= $this->get( 'Items', 'content' );
$this->content_pagination = $this->get( 'Pagination', 'content' );
$this->content_state		= $this->get( 'State', 'content' );
but I dont get any information.
Furthermore while debugging and setting my breakpoint in the controllers display function I never get there?!

What am I doing wrong?

Thanks in advance!

itoctopus
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4025
Joined: Mon Nov 25, 2013 4:35 pm
Location: Montreal, Canada
Contact:

Re: Multiple models - no data retrieved

Post by itoctopus » Wed Aug 20, 2014 9:15 am

I think the main issue that should be addressed first is that you're never getting to the display function. Are you even getting to that controller file at all?

The whole multiple model thing cannot be expected to work if the display function in the controller is not called. I think if you provide us with more context (essentially the code to your extension - just the prototypes), then we can be of more help.
http://www.itoctopus.com - Joomla consulting at its finest
https://twitter.com/itoctopus - Follow us on Twitter

Hamlet55
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Fri Aug 02, 2013 9:27 am

Re: Multiple models - no data retrieved

Post by Hamlet55 » Wed Aug 20, 2014 9:36 am

Yes, since the constructor gets called, I find it interesting that it seems to get called after I close my view, I know I get to the file at least.

This is the call to the view

Code: Select all

index.php?option=com_component&view=compliance&layout=edit&new=1&id=1
As far as I understand it, if you omit the task it should be the "display" task by default.

I am writing a component here, so I am not quite sure which information you need.
Do you need the "main" controller for my component?

itoctopus
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4025
Joined: Mon Nov 25, 2013 4:35 pm
Location: Montreal, Canada
Contact:

Re: Multiple models - no data retrieved

Post by itoctopus » Wed Aug 20, 2014 4:39 pm

It would be great if you can include all the files. Have you tried to hardcode the task in the link (&task=display);
http://www.itoctopus.com - Joomla consulting at its finest
https://twitter.com/itoctopus - Follow us on Twitter


Locked

Return to “Joomla! 3.x Coding”