0

I am getting an warning message in my website :

Warning: Creating default object from empty value in /homepages/16/d381040813/htdocs/components/com_events_booking/models/event.php on line 169

I have opened 169 th line in event.php , the code is:

$row->event->BeforeDisplay = trim(implode("\n", $results)); 

My event.php file is :

  <?php

// no direct access
defined('_JEXEC') or die('Restricted access');

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

/**
 * Event_Booking Component - Event Model
 * @package     Event_Booking
 * @subpackage  Model
 */
class Events_BookingModelEvent extends JModel {
    /** @var int Total of documents */
    var $_total             = null;
    /** @var object Pagination object */
    var $_pagination        = null;
    /** @var string */
    var $nullDate           = null;
    /** @var string */
    var $now                = null;
    /** @var int */
    var $_id                = null;
    /** @var array realty data */
    var $_data              = null;

    /**
     * Constructor.
     */
    function __construct() {
        global $mainframe, $option;
        parent::__construct();

        $this->nullDate = $this->_db->getNullDate();
        $jdate          = JFactory::getDate();
        $this->now      = $jdate->toMySQL();

        $id = JRequest::getInt('id', 0);
        if( !$id ){
            $session    = &JFactory::getSession();
            $user       = JFactory::getUser();
            $joinevent  = $session->get('joinevent');
            if( @count( $joinevent[$user->get('id')] ) ){
                $id = $joinevent[$user->get('id')]['id'];       
            }
        }
        $this->setId($id);
    }

    /**
     * Method to set the identifier
     *
     * @access  public
     * @param   int $id realty identifier
     */
    function setId($id) {
        $this->_id      = $id;
        $this->_data    = null;
    }

    /**
     * Method to get event item data.
     * @access  public
     * @return  object
     */
    function getData($id = null) {
        // Lets load the data if it doesn't already exist
        if (empty($this->_data)) {
            $id     = $id ? $id : $this->_id;
            $query  = 'SELECT a.*, b.id AS bid , b.title AS btitle , c.id AS cid , c.title AS ctitle, c.street, c.city, c.state, c.zip, ct.name AS `country`, c.website, c.latitude, c.longitude'
                . ' FROM #__events_events AS a'
                . ' INNER JOIN #__events_categories AS b ON a.category_id = b.id'
                . ' INNER JOIN #__events_venues AS c ON a.venue_id = c.id'
                . ' LEFT JOIN #__events_countries AS ct ON ct.code LIKE c.country'
                . ' WHERE a.published = 1 AND a.id = '. (int) $id
                ;
            $this->_db->setQuery($query);
            $this->_data    = $this->_db->loadObject();
        }

        if (!$this->_data->id) {
            JError::raiseError( 404, JText::_('COM_EVENTS_BOOKING_EVENT_NOT_FOUND'));
        }

        return $this->_data;
    }
    /**
     * Method to get group item data.
     * @access  public
     * @return  array
     */
    function getGroup($id = null) {
        $query  = 'SELECT g.* FROM #__events_groups as g'
                . ' WHERE g.published = 1 AND a.id = '. (int) $id
                ;
        $this->_db->setQuery($query);
        $row    = $this->_db->loadObject();
        return $row;
    }

    /**
     * Method to get Expired item data.
     * @access  public
     * @return  array
     */
    function getExpired() {
        $date   = new JDate();
        $id     = $this->_id;
        $query  = 'SELECT COUNT(*) FROM #__events_events AS a WHERE a.id = '.(int)$id.' AND a.published = 1 AND a.expired > '.$this->_db->Quote($date->toMySQL());
        $this->_db->setQuery($query);
        $row = $this->_db->loadResult();
        return $row;
    }

    /**
     * Method to get Expired Capacity.
     * @access  public
     * @return  array
     */
    function getCapacity() {
        $data   = $this->getData();
        $id     = $this->_id;
        $result = $this->getMemberCapacity($data->capacity);
        return $result;
    }
    /**
     * Method to get Member Capacity COM_EVENTS_BOOKING_JOIN_EVENT.
     * @access  public
     * @return  array
     */
    function getMemberCapacity($capacity=0) {
        $id     = $this->_id;
//      $query  = 'SELECT COUNT(*) FROM #__events_members AS a WHERE a.event_id = '.(int)$id;
        $query  = 'SELECT COUNT(*)'
                . ' FROM #__events_members AS a'
                . ' INNER JOIN #__events_bookings AS b ON b.id = a.booking_id'
                . ' WHERE a.event_id = '.(int)$id
                . ' AND b.approved = 1'
                . ' AND a.approved = 1'
                ;

        $this->_db->setQuery($query);
        $row    = $this->_db->loadResult();
        $result = array();
        $result['m_capacity'] = $row;
        $result['e_capacity'] = (int)($capacity-(int)$row);
        return $result;
    }


    function execPlugins(&$row, $view, $task){
        $params     = &JComponentHelper::getParams('com_events_booking');
        $limitstart = JRequest::getInt('limitstart');
        //Import plugins
        $dispatcher = &JDispatcher::getInstance();
        JPluginHelper::importPlugin ('content');

        $row->text = $row->description;

        $results = $dispatcher->trigger('onBeforeDisplay', array ( 'com_events_booking.event', &$row, &$params, $limitstart));
        $row->event->BeforeDisplay = trim(implode("\n", $results));

        $results = $dispatcher->trigger('onAfterDisplay', array ( 'com_events_booking.event', &$row, &$params, $limitstart));
        $row->event->AfterDisplay = trim(implode("\n", $results));

        $results = $dispatcher->trigger('onAfterDisplayTitle', array ( 'com_events_booking.event', &$row, &$params, $limitstart));
        $row->event->AfterDisplayTitle = trim(implode("\n", $results));

        $results = $dispatcher->trigger('onBeforeDisplayContent', array ( 'com_events_booking.event', &$row, &$params, $limitstart));
        $row->event->BeforeDisplayContent = trim(implode("\n", $results));

        $results = $dispatcher->trigger('onAfterDisplayContent', array ( 'com_events_booking.event', &$row, &$params, $limitstart));
        $row->event->AfterDisplayContent = trim(implode("\n", $results));

        $dispatcher->trigger('onContentPrepare', array ( 'com_events_booking.event', &$row, &$params, $limitstart));
        return $row;
    }

    /**
     * Method to store the booking
     *
     * @access public
     * @param $data
     * @return boolean True on success
     */
    function store($data) {
        //$row = JTable::getInstance('form', 'Table');
        $row =& $this->getTable('event');

        // bind the form fields to the version table
        if (!$row->bind($data)) {
            $this->setError($this->_db->getErrorMsg());

            return false;
        }

        // make sure the category is valid
        if (!$row->check()) {
            $this->setError($this->_db->getErrorMsg());
            return false;
        }

        // store the category table to the database
        if (!$row->store()) {
            $this->setError($this->_db->getErrorMsg());

            return false;
        }
        return $row;
    }

I googled a day, but no result. Please help me to hide this warning or solving this.

the page url in which error shown: http://www.lefoodist.biz/calendar-gb/calendar-hosted-gastronomic-dinners?view=event&id=478#box-details

2
  • you can hide errors with error_reporting(E_NONE) or setting proper value in php.ini or with function ini_set() you can also use @ operator to hide error. The error may be cause also by previous line so you should include this line to your post as well Commented May 17, 2013 at 11:47
  • yes i have used it and now got result @robert Commented May 17, 2013 at 12:14

1 Answer 1

2

Nowhere have you created a $row->event object. So when you set $row->event->BeforeDisplay, the BeforeDisplay object is being created against something that hasn't been set. If you do something like $row->event = new stdClass(); before your events start to run, this should clear it up.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.