fbpx
Introducing JD Builder - Now Beat the unbeatable designsDownload For Free
Welcome, Guest
Username: Password: Remember me

Like using Astroid?

Help us improve Astroid by providing some quick feedback.

Take the survey

TOPIC: (SOLVED) PHP Warning: No such file or directory

[Solved] PHP Warning: No such file or directory 1 year 9 months ago #5347

  • edjec
  • edjec's Avatar
  • Offline
  • New Member
  • Posts: 11
  • Karma: 0
Hello,

I’ve recently noticed our server php error file filled with thousands of instances of the following error message:

PHP Warning: require_once(/home/vcoaor5/public_html/libraries/joomla/document/html/renderer/head.php): failed to open stream: No such file or directory in /home/vcoaor5/public_html/templates/jd_dallas/error.php on line 42

In researching the cause, I found that Joomls 3.8.x no longer uses libraries/joomla/document/html/renderer/head.php and since the template is trying to open this file, that is what is throwing the error message.

The Joomla forum thread https://forum.joomla.org/viewtopic.php?t=956021 suggests deleting the line 42 code line -
require_once(JPATH_LIBRARIES.'/joomla/document/html/renderer/head.php');
which does stop the errors from being thrown and I did not immediately notice any problems with the site, although I did not test thoroughly.

Another post to this thread suggests replacing the above code with:
$document = JFactory::getDocument();
$renderer = $document->loadRenderer('head');
$header_contents = $renderer->render(null);

In the Dallas error.php file you follow line 42 with:
$header_renderer = new JDocumentRendererHead($doc);
$header_contents = $header_renderer->render(null);
Which is similar to the code immediately above.

However, in this forum, I discovered a similar issue with the jd_conference template here: https://www.joomdev.com/forum/jd-conference/1167-website-malware-warning where in the updated error.php file you have replaced line 42 with:
$header_contents = '';
if(!class_exists('JDocumentRendererHead')) {
  $head = JPATH_LIBRARIES . '/joomla/document/html/renderer/head.php';
  if(file_exists($head)) {
    require_once($head);
  }
}

I assume you are just making the template backwards compatible with previous versions of Joomla while ignoring head.php for current versions?

Since I have upgraded to J3.8.3 and will not need backwards compatibility, what is the preferred code to use here?

Thank you,

Ed
Last Edit: 1 year 8 months ago by edjec. Reason: issue solved
The topic has been locked.

PHP Warning: No such file or directory 1 year 9 months ago #5356

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Posts: 2851
  • Thank you received: 439
  • Karma: 91
Hi Ed,

The framework is all about making is backward compatible and possibly in the next update or two it will be gone. For the movement you may apply the fix and replace it with the code below and that should fix it.
$header_contents = '';
if(!class_exists('JDocumentRendererHead')) {
  $head = JPATH_LIBRARIES . '/joomla/document/html/renderer/head.php';
  if(file_exists($head)) {
    require_once($head);
  }
}
Thank You,
If you like our support and products, tweet us at joomdev and let the world know about it.
The topic has been locked.
The following user(s) said Thank You: edjec

PHP Warning: No such file or directory 1 year 9 months ago #5358

  • edjec
  • edjec's Avatar
  • Offline
  • New Member
  • Posts: 11
  • Karma: 0
That's what I thought you were doing with this snippet. I will edit the error.php file and add this.

Thank you,

Ed
The topic has been locked.

PHP Warning: No such file or directory 1 year 9 months ago #5364

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Posts: 2851
  • Thank you received: 439
  • Karma: 91
Happy Holidays Ed!
Thank You,
If you like our support and products, tweet us at joomdev and let the world know about it.
The topic has been locked.

PHP Warning: No such file or directory 1 year 8 months ago #5369

  • edjec
  • edjec's Avatar
  • Offline
  • New Member
  • Posts: 11
  • Karma: 0
Thank you again for your help and Happy Holidays to you as well!
The topic has been locked.
Time to create page: 0.259 seconds