2

In Joomla 3.x versions I use JResponse to get and set the body.

function onAfterRender() {
          $content = JResponse::getBody();
          ...
    }

But in Joomla4 it returns Class 'JResponse' not found. So how to get the body in Joomla4?

Thanks

2

According to the documentation, JApplicationWeb seems to be alive and well in Joomla4.

since 2.5.0

note As of 4.0 this class will be abstract

  • The getters:

    JApplicationWeb::getBody()
    

    Or

    JFactory::getApplication()->getBody()
    
  • The setters:

    JApplicationWeb::setBody()
    

    Or

    JFactory::getApplication()->setBody()
    

Relevant references and examples:

  • JFactory::getApplication()->getBody() is definitely recommended way. – George Wilson Oct 25 at 15:40
  • Tell me more. Better yet, tell everyone in an answer please. You know better than me. Why is one better than the other? @George – mickmackusa Oct 25 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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