0

While this code working in Joomla 3x with PHP 8, it is not working in Joomla 4x -- it is showing error class to undefined method

public function display($tpl = null)
{
    $app = Factory::getApplication();
    $db  = Factory::getDBO();
    $user = Factory::getUser();
    $this->state = $this->get('State');
    $this->item = $this->get('Data');
    $this->params = $app->getParams('com_car');

    $model      = $this->getModel();
    $modelcar   = $this->getModel( 'product' );
        
    $id  = $app->input->get('id','','default','int');
    $vid = $app->input->get('vid','','default','int');
        
    $prodDet = $modelcar->loadProduct($id,$vid);
    $this->assignRef('prodDet'  , $prodDet);
        
    $CatName = $modelcar->getCatName($id);
    $this->assignRef('CatName'  , $CatName);

Here this line is the problem area:

$prodDet = $modelcar->loadProduct($id,$vid);
$this->assignRef('prodDet'  , $prodDet);
    
$CatName = $modelcar->getCatName($id);
$this->assignRef('CatName'  , $CatName);

1 Answer 1

1

Joomla\CMS\MVC\View\HtmlView::assignRef() has been removed. Use native PHP syntax:

$this->CatName = &$CatName;

In most cases you probably don't even need to assign by reference. So use this instead:

$this->CatName = $CatName;

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.