Model getData not called

Locked
andri
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Sat Aug 23, 2008 10:40 pm

Model getData not called

Post by andri » Sun Aug 24, 2008 6:06 pm

hope anyone sees my minor code error. I'm building a custom mvc component which is in a running state. I built it on top of some helloworld example (http://joomlaequipment.com/content/view/47/74/)
I then was going to add models and tables without luck.

it's like model getData is never called in the view.
Here is my model code ( /administrator/components/com_aefingatoflur/models/deildir.php)

Code: Select all

jimport( 'joomla.application.component.model' );

class AefingatoflurModelDeildir extends JModel
{
	var $_data;

	function _buildQuery()
	{
		$query = ' SELECT * '
			. ' FROM #__deildir '
		;
		return $query;
	}

	function getData()
	{
		echo 'test'; //doesn't show up
		// Lets load the data if it doesn't already exist
		if (empty( $this->_data ))
		{
			$query = $this->_buildQuery();
			$this->_data = $this->_getList( $query );
		}
		echo 'test'; //doesn't show up
		return $this->_data;

	}
and here is my view code

Code: Select all

jimport( 'joomla.application.component.view');

class AefingatoflurViewDeildir extends JView
{
	function display($tpl = null)
	{
		JToolBarHelper::title(   JText::_( 'Deildir' ), 'generic.png' );
		JToolBarHelper::deleteList();
		JToolBarHelper::editListX();
		JToolBarHelper::addNewX();

		// new start
		// Get data from the model
		$items		= &$this->get('Data');
		$this->assignRef('items', $items);
		// new end

		parent::display($tpl);
	}
}
any thoughts on why getData doesn't get called?
I read somewhere that classnames should match XxxViewYyyy and XxxModelYyyy which I have followed

User avatar
fire2006
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 111
Joined: Tue Jun 06, 2006 7:46 am
Location: Vancouver
Contact:

Re: Model getData not called

Post by fire2006 » Tue Aug 26, 2008 2:23 pm

Hey buddy, im learning about models too right now, when I get something, Ill send it your way! - Ive subcribed to this question...
Paul Preibisch - Educational Technologist
Fire Centaur - English Village - Secondlife
http://slurl.com/secondlife/English%20V ... %20Village&

User avatar
fire2006
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 111
Joined: Tue Jun 06, 2006 7:46 am
Location: Vancouver
Contact:

Re: Model getData not called

Post by fire2006 » Tue Aug 26, 2008 2:33 pm

There's a really good model thread here: http://forum.joomla.org/viewtopic.php?f ... 02&start=0

Im gonna try it tomorrow
Paul Preibisch - Educational Technologist
Fire Centaur - English Village - Secondlife
http://slurl.com/secondlife/English%20V ... %20Village&

secteur
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 146
Joined: Tue Nov 08, 2005 9:32 am
Location: Malaysia

Re: Model getData not called

Post by secteur » Wed Aug 27, 2008 5:29 pm

Hi,

tested your code and it works...
Make sure that the view is in a file called view.html.php in the folder /administrator/components/com_aefingatoflur/views/deildir

Model seems to be in the right place... Names of classes are correct.

Could you please post the code for your controller.php? Also do a echo 'test' or similar in the view itself to see if the view is called at all.

Thanks


Locked

Return to “Joombie Coding Q/A”