HTACCESS / SEF stopping Jrequest from working

For Joomla! 2.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Note: All 1.6, 1.7 and 3.5 releases have reached end of life and should be updated to 3.x.

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Locked
MOLEDesign
Joomla! Apprentice
Joomla! Apprentice
Posts: 7
Joined: Thu Jun 12, 2014 11:23 pm

HTACCESS / SEF stopping Jrequest from working

Post by MOLEDesign » Thu Jun 12, 2014 11:27 pm

I am working on a client's website which is based on the Joomla 2.5 framework. With SEF turned off (the in built Joomla version) the URL is this

Code: Select all

http://(domain)/index.php?option=com_cmgroupbuying&view=alldeals&Itemid=424
The user has a plugin, I have built into a plugin the line to make sure this plugin only fires when the component CMGroupbuying is in use

Code: Select all

$component = JRequest::getCmd('option'); 
if($component =='com_cmgroupbuying')
               { etc etc }
With SEF turned off, this works beautifully. However when I enable SEF the URL turns into

Code: Select all

http://(domain)/the-deals
and the detection script stops working as joomla just no longer sees the Request::getCmd('option'); being equal to com_cmgroupbuying which to be honest, blows me away as it renders getCmd totally useless. I have seen other people suffer with this in the part but not found any definitive fix. I have seen some folks quote that 'JRequest works with or without SEF, but I am seeing otherwise

Can anyone offer a solution to stop this failure of Joomla, either by some extra lines in the DEFAULT htaccess fault to retain this information for joomla to use, or maybe detecting part of the URL so I can build a detector script from that, or any way to fix this using other clever methods

Many thanks

User avatar
NathanHawks
Joomla! Ace
Joomla! Ace
Posts: 1900
Joined: Wed Oct 02, 2013 6:17 pm
Location: Washington state, U.S.
Contact:

Re: HTACCESS / SEF stopping Jrequest from working

Post by NathanHawks » Sun Jun 15, 2014 9:41 am

I believe the data is still in the JRequest object. Check these:

1. JRequest::get('cmd') (ideally, more like what you're used to)

2. Find some way of getting at the current JController object and ask it for getName():
http://joomla25docs.phpdb.net/Joomla-Pl ... hodgetName

PS: Don't despair -- I'm not 100% sure where, but somewhere, Joomla knows the name of its currently-active component, and your plugin can get at it. Just gotta find it. It's late and I'm not sure off the top of my head how to access the currently-running JControllerLegacy instance, but #2 above should give you a definite route to a solution (you may have to code around multiple controller names, depending on the extension's complexity).
Save time - hire me for your Joomla to-do list! http://nathanhawks.us/joomla


Locked

Return to “Joomla! 2.5 Coding”