0

I faced with error

Trying to get property of non-object The error disappears when I use my own widget. Here is the code of this widget

   class OtherProductionWidget extends CmsWidget
{
     public $category;
     public $product;

     public function init()
    {

        if(!$this->category)
           return false;
           $models = Product::getOtherProducts($this->category,$this->product);
        if($models)
        $this->render('view',array('models'=>$models));

    }

}

The message of error indicates that I have problem in this line:

    $this->render('view',array('models'=>$models));

The $models variable is not empty - I cheked it. Here is which I use this widget:

<?php $this->widget('application.widgets.otherProductionWidget.OtherProductionWidget',array('category'=>$model->category_id,'product'=>$model->id));?>

The $model variable also not empty. Tell me pleas what I doing wrong?

Here is a view part of widget:

             <?php foreach($models as $model):?>
                <a class="product dib"
                   href="<?php echo $model->link?>"
                   style="z-index: 6">
                        <span class="dib product-data pos-absolute text-align-justify">
                        <span class="text dib"><?php echo $model->name?></span><span class="dib image">
                        <img alt="<?php echo $model->link?>" class="dib thumb"
                             src="<?php echo $model->getImage(160,160,false)?>"
                             title="<?php echo $model->link?>">
                        </span><span class="dib width100 pos-relative row-fluid">
                        <span class="details">
                        <span class="dib details-inner"><?php echo Translation::t('More');?></span>
                        </span>
                        </span>

                        </span>
                </a>
                <?php endforeach?>
YuriiChmil
  • 441
  • 1
  • 5
  • 18

0 Answers0