Joomla! Discussion Forums



It is currently Thu Nov 26, 2009 7:17 pm (All times are UTC )

 




Post new topic Reply to topic  [ 4 posts ] 
Author Message
Posted: Fri Nov 06, 2009 6:39 pm 
Joomla! Intern
Joomla! Intern
Offline

Joined: Thu Jul 17, 2008 2:26 pm
Posts: 86
Can't seem to figure out what's causing this error message. I think it might have to do with my controller though.

admin/controller.php
Code:
<?php

defined('_JEXEC') or die ('restricted access');

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

class CbcolaController extends JController

{

   function display ()

   {

      /*echo "the display() function of the controller :) <br />";*/

      //get a refrence of the page instance in joomla

      $document=& JFactory::getDocument();

      //get the view name from the query string

      $viewName = JRequest::getVar('view', 'registration');



      $viewType= $document->getType();

      //get our view

      $view = &$this->getView($viewName, $viewType);

      //get the model
     $model = &$this->getModel($viewName, 'ModelCbcola');
   
    
      //some error chec

    

    

      if (!JError::isError($model))

      {

         $view->setModel ($model, true);

      }



      //set the template and display it

      $view->setLayout('default');

      $view->display();

   }

}

?>


admin/controllers/registration.php
Code:
<?php

defined('_JEXEC') or die ('restricted access');

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

class CbcolaControllerRegistration extends CbcolaController
{
   function display ()
   {
      

      //get a refrence of the page instance in joomla
      $document=& JFactory::getDocument();

      //get the view name from the query string
      $viewName = JRequest::getVar('view', 'registration');
      $viewType= $document->getType();

      //get our view
      $view = &$this->getView($viewName, $viewType);

      //get the model
      $model = &$this->getModel('Registration', 'ModelCbcola');
    
      //some error chec

      if (!JError::isError($model))
      {
         $view->setModel ($model, true);
      }

      //set the template and display it

      $view->setLayout('default');

      $view->display();

   }

}

?>


admin/models/registration.php
Code:
<?php
defined('_JEXEC') or die ('restrinced access');
jimport('joomla.application.component.model');
class CbcolaModelRegistration extends JModel
{
   var $_query = null;
   function __construct()
   {
      parent::__construct();
   }
   function Pages()
   {
   $query = ' SELECT * FROM jos_CB_Cola';
   $query = mysql_query($query);     
   $this->_query = $query;
   
   return $this->_query;
   }
   
 
 
   
}
?>


error message:
Fatal error: Call to a member function getName() on a non-object in /home/account6/public_html/MedTech/libraries/joomla/application/component/view.php on line 449


Top
  E-mail  
 
Posted: Fri Nov 06, 2009 7:19 pm 
Joomla! Intern
Joomla! Intern
Offline

Joined: Thu Jul 17, 2008 2:26 pm
Posts: 86
Nevermind, was modifying the wrong controller file.

:laugh:


Top
  E-mail  
 
Posted: Mon Nov 09, 2009 12:12 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Fri Oct 09, 2009 8:58 am
Posts: 11
Location: Chennai, Tamilnadu, India
don't you write any views ie. view.html.php files?

_________________
Best Regards,
SelvaG


Top
  E-mail  
 
Posted: Mon Nov 09, 2009 2:23 pm 
Joomla! Intern
Joomla! Intern
Offline

Joined: Thu Jul 17, 2008 2:26 pm
Posts: 86
Yes, I think the problem was that I was calling a model within the view which was never declared via the controller though.

Code:
$viewName = JRequest::getVar('view', 'registration');
      $viewType= $document->getType();

      //get our view
      $view = &$this->getView($viewName, $viewType);

      //get the model
      $model = &$this->getModel($viewName, 'ModelCbcola');
    
      if (!JError::isError($model))
      {
         $view->setModel ($model, true);
      }


or rather in my case the primary cbcola.php file needed to be corrected so that it called the appropriate controller.

cbcola.php
Code:
<?php

defined ('_JEXEC') or die ('restricted access');
require_once (JPATH_COMPONENT.DS.'controller.php'); 
foreach(glob(JPATH_COMPONENT.DS.'/controllers/*.php') as $controller)//wasn't here before
{
   require_once($controller);
}
    
$control = 'CbcolaController'.JRequest::getVar('view');
$controller = new $control;

$controller->execute(JRequest::getVar('task'));
$controller->redirect();
   
?>


seems to be working now. I'll iron out any more bugs as they come :P


Top
  E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

Quick reply

 



Who is online

Users browsing this forum: hdegrijs, Kurtwoodfin, thlas77 and 37 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group