creating a new J4 site from a J3 site Topic is solved

Need help installing Joomla! 4.x? For all Joomla! 4.x installation issues please use this forum.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Post Reply
rottenberg
Joomla! Apprentice
Joomla! Apprentice
Posts: 27
Joined: Thu Nov 16, 2006 10:29 am

creating a new J4 site from a J3 site

Post by rottenberg » Fri Aug 05, 2022 3:06 pm

J4 version : 4.1.5
PHP version : 7.4


hello
i'm creating a new J4 site from J3 existing one.

I have a J3 code which is running perfectly.
It's bugging in J4.

After some search I have found that the following code is the bug :

Code: Select all

<?php
$uri    = & JFactory::getURI();
$Monurl = parse_url(JURI::root());
I have been adviced to change some code and to use :

Code: Select all

<?php
$uri    = & JFactory::getURI();
$Monurl = parse_url(Joomla\CMS\Uri\Uri::root());
In J4 I get the following error message :

Code: Select all

Call to undefined method Joomla\CMS\Factory::getURI()
How can I correct it for working in J4.

Thank you for your recommandations
Best regards

Michel Rottenberg

User avatar
ceford
Joomla! Guru
Joomla! Guru
Posts: 988
Joined: Mon Feb 24, 2014 10:38 pm
Location: Edinburgh, Scotland
Contact:

Re: creating a new J4 site from a J3 site

Post by ceford » Fri Aug 05, 2022 4:54 pm

First thing I noticed is that $uri is not used in the code snippet you presented. Second is that Joomla 4 uses namespaces so this would go at the top of your file:

use Joomla\CMS\Uri\Uri;

But I think you can do it with your code by adding a leading \

$Monurl = parse_url(\Joomla\CMS\Uri\Uri::root());

The chances are you will fix that bug and then go on to the next one, and the next, ad infinitum.

Which Joomla 3 extension are you trying to fix?

User avatar
leolam
Joomla! Master
Joomla! Master
Posts: 20439
Joined: Mon Aug 29, 2005 10:17 am
Location: Netherlands/ Germany/ S'pore/Bogor/ North America
Contact:

Re: creating a new J4 site from a J3 site

Post by leolam » Fri Aug 12, 2022 3:28 pm

Why don't you run the pre-Joomla 4 update script which tells you exactly which extensions are not compatible with J4?

Leo 8)
Joomla's #1 Professional Services Provider:
#Joomla Professional Support: https://gws-desk.com -
#Joomla Specialized Hosting Solutions: https://gws-host.com -

rottenberg
Joomla! Apprentice
Joomla! Apprentice
Posts: 27
Joined: Thu Nov 16, 2006 10:29 am

Re: creating a new J4 site from a J3 site

Post by rottenberg » Thu Aug 18, 2022 6:42 pm

I don't want to upgrade my site from J3 to J4 as it's an old site with a number of menu which are nomore used.
I prefer create a new site with live options.

I have solved my initial problem in another way.


Post Reply

Return to “Installation Joomla! 4.x”