1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Template Error

Discussion in 'XenForo Development Discussions' started by Gossamer, Jun 4, 2014.

  1. Gossamer

    Gossamer Active Member

    Hello! So, I'm trying to pass the variable $ExistingReserve from my Controller into a template. However, when the template loads I receive this error:

    Here is the relevant part of my ControllerPublic:
    PHP:
        public function actionIndex()
        {
            
    //Check for Existing Reserve
            
    $visitor XenForo_Visitor::getInstance();
           
            
    $reserveModel $this->_getReserveModel();
           
            if(
    $reserveModel->getReserveByUser($visitor['user_id']))
            {
                
    $ExistingReserve $reserveModel->getReserveByUser($visitor['user_id']);
            }
            else
            {
                
    $ExistingReserve 0;
            }
           
            
    //Get all rows from our table and other data to pass to the template so it can be used
            
    $viewParams = array(
                
    'Reserves' => $this->_getReserveModel()->getAllReserves(),
                
    'ExistingReserve' => $ExistingReserve);
           
            return 
    $this->responseView('Reservations_ViewPublic_Reserves''goss_reserves'$viewParams);
        }
    And my model with the getReserveByUser function:
    PHP:
        public function getReserveByUser($user_id)
        {
            return 
    $this->_getDb()->fetchRow('SELECT * FROM xf_goss_reservation WHERE user_id = ?'$user_id);
        }
    It looks like the error comes from how I'm attempting to set $ExistingReserve using the getReserveByUser function. What's the correct way to pass the information?
     
  2. Gossamer

    Gossamer Active Member

    Woops. This actually turned out to be a really silly error. I forgot to actually call the field I was looking for in the template and instead was calling the whole array. XD

    All set now!
     

Share This Page