JomSocial Profile Links and Joomla Core SEF
UPDATE: It turns out this was an issue with JomSocial Registration Redirector, found at http://www.joomlaxi.com/products/free-products/jom-social-registration-redirector.html and NOT JomSocial. The original article is preserved below...
I've been having "fun" assisting in maintaining a site using JomSocial, and recently ran across an interesting issue. The search engine friendly URLs created for JomSocial by JRoute were not being created properly for links under the Profile tab: changeAvatar, editDetails, etc. All of these links would just redirect to the Profile page. After fiddling around with the settings, ensuring the component was up to date, and double checking the .htaccess, I reasoned that it must be a bug in the router.php. After slogging through the code, I managed to find a fix.
The configuration on this site has SEO > URL Format set to "/username/features" and SEO > SEF Compatibility Fix set to "no", in case that makes a difference.
In the CommunityBuildRoute function in JomSocial's router.php, there is a conditional that checks the SEF settings:
if($config->get('sef') == 'feature') { } else { ...
Inside the "else" statement, there is a second conditional that determines if "userid" is a key in the $query:
if(array_key_exists( 'userid', $query)) { ...
At the end of this conditional, I added an "else" statement to set the 'userid' if the view is "profile", as that is necessary. If you're following along, change this:
if(array_key_exists( 'userid', $query)) { ... unset($query['userid']); }
to this:
if(array_key_exists( 'userid', $query)) { ... unset($query['userid']); } else if( array_key_exists( 'view', $query ) && 'profile' == @$query['view'] ) { $user = JFactory::getUser(); $segments[] = $user->username; }
This solved the issue on the site I was working on; your mileage may vary as far as how well it works for you!