1

JRequest Remove from Joomla 4 then how i must use this method

for example

    $controller->execute( JRequest::getCmd('task', $view)

not work i must change it to what ?

2 Answers 2

4

Use Joomla\Input\Input class. Instance relevant to the current request can be accessed through the application:

use Joomla\CMS\Factory;

$controller->execute(Factory::getApplication()->getInput()->get('task', $view));

Inside controllers you should already have the input instance injected which you could use like this:

$this->input->get('inputVar');
1
  • can you check my code and if this is true tell me ? Commented May 17, 2022 at 13:52
0

This is some of the current code inside my controller:

function add() {
    if(JRequest::checkToken( 'get' )) {
        JRequest::checkToken( 'get' ) or die( 'Invalid Token' );
    } else {
        JRequest::checkToken() or die( 'Invalid Token' );
    }
    JRequest::setVar('hidemainmenu', 1);        
    $model = $this->getModel('albums');
    
    $view = $this->getView('albums', 'html');               
    $view->setModel($model, true);      
    $view->setLayout('add');
    $view->add();
}

It must be changed to:

function add() {
    if(Factory::getApplication()->getInput()->get('get')) {
        Factory::getApplication()->getInput()->get('get') or die( 'Invalid Token' );
    } else {
        JFactory::getApplication()->getInput() or die( 'Invalid Token' );
    }
    
    $this->input->get('hidemainmenu', 1);   
    $model = $this->getModel('albums');
    
    $view = $this->getView('albums', 'html');               
    $view->setModel($model, true);      
    $view->setLayout('add');
    $view->add();
}

Your Answer

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

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