2

I'm currently in the forced transition from PHP 5.6 to 7.1 (or 7.2, both are an option) for my website. I have two websites, the one is working fine but the other isn't running on 7.1 or .2.

I get the following error messages:

[Thu Oct 25 09:25:21.985120 2018] [:error] [pid 12006] PHP Deprecated: Non-static method Joomla\\CMS\\Application\\CMSApplication::getMenu() should not be called statically, assuming $this from incompatible context in /home/public/sites/www.modderaandebanden.nl/libraries/src/Application/SiteApplication.php on line 275
[Thu Oct 25 09:25:21.985130 2018] [:error] [pid 12006] PHP Strict Standards: Only variables should be assigned by reference in /home/public/sites/www.modderaandebanden.nl/templates/siteground-j16-1/templates.php on line 15

I get the problem on all my pages (it uses the same template all around). This is what I get when I open the templates.php of the Siteground J16-1 template I'm currently using:

<?if( $sg == 'banner' ):?>

    <?php if (JRequest::getVar('view') == 'frontpage'):?>

    <!-- SIDE BEGIN --><!-- SIDE END -->

    <?php endif?>

<?else:?>

    <?php echo $app->getCfg('sitename'); ?>, Powered by <a href="http://joomla.org/" class="sgfooter" target="_blank">Joomla!</a>



    <?php $menu = &JSite::getMenu();

    if ($menu->getActive() == $menu->getDefault()) :?>

        <!-- FOOTER BEGIN --><a href="http://www.siteground.com/cpanel-hosting.htm" target="_blank">Hosting with cPanel by SiteGround</a><!-- FOOTER END -->

    <?php endif ?>



<?endif;?>

Please let me know if this might clarifies the problem. Please excuse my noobiness... :-D

www.modderaandebanden.nl is my site.

Can anybody tell me what's going on here. Is it the template that's not suited to usage with PHP 7?

Thanks in advance

Bram
  • 21
  • 2
  • Most likely using older variant of getMenu. What is the particular URL you are getting it on? Open that templates.php and look for a reference there. If you update your answer with the broken code, we can give you the correct snippet. – YellowWebMonkey Oct 25 '18 at 16:43
  • Just added some extra info. Hope this might clarify things.... Thanks. – Bram Oct 26 '18 at 17:45
  • 1
    Check out https://stackoverflow.com/questions/15922391/strict-standards-non-static-method-jsitegetmenu-should-not-be-called-static – YellowWebMonkey Oct 26 '18 at 18:10
  • Awesome! This works. So simple (to me it's still magic hehehe). Thanks a ton! – Bram Oct 28 '18 at 14:51

1 Answers1

2

This is warning and notices. This isn't errors !

Normally you can hide that : Joomla configuration > Server tab > Error report -- Set it to minimum or none.

Also you can modify this setting in server php.ini configuration file or set it in a php.ini file in your website root folder (only possible on some servers).

But finally you should fix your code to use new Joomla Framework methods. For example to get menu, use :

// Get Joomla! instance
$jAp = JFactory::getApplication();
// Get variables
$menu = $jAp->getMenu();

And look at this for Get vars : https://docs.joomla.org/Retrieving_request_data_using_JInput

Netenvie
  • 21
  • 4