Howto Reverse SEF URL to NON-SEF URL?

Discuss Search Engine Optimization in relation to Joomla!. This forum will also have discussions on SEF/SEO Joomla! extensions.

Moderator: General Support Moderators

Locked
kfci
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu Jul 14, 2011 3:15 pm

Howto Reverse SEF URL to NON-SEF URL?

Post by kfci » Thu Jul 14, 2011 3:31 pm

I have the requirement to find out the NON-SEF URL for any given joomla page for a custom plugin I am writing.

I have the SEF URL delivered to my plugin, which is actually the $_SERVER['HTTP_REFERER'] global variable and need to find the internal NON-SEF URL for this variable.

I have started reverse engineering the JRoute and router.php part of Joomla, but thought someone might help direct me to the answer easily?

Below is my code so far: -

Code: Select all

$Referer = $_SERVER['HTTP_REFERER'];
$Internal_Referer = ????;
Once I have the internal/non-sef URL for the referer I can perform the rest of my work, which mainly involves checking the component which the content refers to and then depending on that my plugin will display certain information or not.

I'm not sure if I need to use jimport/directly import the router.php?

Any help much appreciated.

User avatar
HobbesPDX
Joomla! Apprentice
Joomla! Apprentice
Posts: 41
Joined: Sat Feb 14, 2009 10:17 am
Location: Portland, Oregon
Contact:

Re: Howto Reverse SEF URL to NON-SEF URL?

Post by HobbesPDX » Thu Jan 03, 2013 5:16 am

Did you ever reach a conclusion to your project?
Were you able to reverse-lookup via the JRoute::_()?

hotdogsushi
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu Jan 31, 2013 6:58 pm

Re: Howto Reverse SEF URL to NON-SEF URL?

Post by hotdogsushi » Thu Jan 31, 2013 7:08 pm

This worked for me in Joomla! 2.5.5.

Code: Select all

$Referer = $_SERVER['HTTP_REFERER'];

$router =& JSite::getRouter();
$router->setMode(0); // Set mode to Parse RAW URL.
$u =& JURI::getInstance( $Referer );
$routingArray = $router->parse($u);

// Debugging.
echo "<pre>";
print_r($routingArray);
echo "</pre>";

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 26198
Joined: Mon Oct 27, 2008 9:27 pm
Location: Akershus, Norway

Re: Howto Reverse SEF URL to NON-SEF URL?

Post by Per Yngve Berg » Thu Jan 31, 2013 7:44 pm

Have you tried jrequest::getvar ()

User avatar
HobbesPDX
Joomla! Apprentice
Joomla! Apprentice
Posts: 41
Joined: Sat Feb 14, 2009 10:17 am
Location: Portland, Oregon
Contact:

Re: Howto Reverse SEF URL to NON-SEF URL?

Post by HobbesPDX » Thu Jan 31, 2013 7:49 pm

@Per -- sorry; how does that apply? I certainly use JRequest::getVar() regularly, but I'm trying to work with JRoute::_() here.

(Thanks, @hotdogsushi!!)

mharvester
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Fri Jun 07, 2013 6:29 pm

Re: Howto Reverse SEF URL to NON-SEF URL?

Post by mharvester » Fri Jun 07, 2013 7:07 pm

Code: Select all

$u =& JURI::getInstance( $Referer );
Be careful with it, J router remove current strlen(basepath) from JUri::_path, so if you have link without basepath and access it from the page with basepath the _path will be cutted wrong. Add a little fix

Code: Select all

$uri = &JURI::getInstance( $Referer );
$base = JURI::base( true );
if( !empty($base) ){
	$uri->setPath( $base.'/'.$uri->getPath() );
}


Locked

Return to “Search Engine Optimization (Joomla! SEO) in Joomla! 1.5”