Username URL in Joomla 3.3

I am looking for a solution to show url with username. I am using Joomla stable version 3.3.0.

Ex. site_url / userp-username

I tried to solve this problem with .htaccess with the following rules that I used for my main PHP websites.

RewriteRule ^userp-([a-zA-Z0-9-_]+)/?$ site_url/index.php?option ... er_name=$1 [R=301,L]

      

When I click on a URL like http://sitename.com/userp-vishal07 it executes the code I want to call for that URL and it shows the results correctly, But the URL doesn't stay the same and turns into http://vicciivital.com/index.php/en/component/users/profile?layout=view_profile&user_name=vishal07

I can't figure out how Joomla redirection works. Please correct me if I make any mistakes here.

+3


source to share


1 answer


For reasons I never understood, the com_users router does not route any profiles other than its own user profile.

/**
 * Method to get a route configuration for the profile view.
 *
 * @return  mixed   Integer menu id on success, null on failure.
 * @since   1.6
 */
public static function getProfileRoute()
{
    // Get the items.
    $items  = self::getItems();
    $itemid = null;

    // Search for a suitable menu id.
    //Menu link can only go to users own profile.

    foreach ($items as $item)
    {
        if (isset($item->query['view']) && $item->query['view'] === 'profile')
        {
            $itemid = $item->id;
            break;
        }

    }
    return $itemid;
}

      



What you need to do is extend this method to handle all profiles. Just make sure you are dealing with a situation where there is a content item or tag with the same alias as the alias for the user.

In general, the easiest way is to use com_contact as a profile. Enabling the contact creator plugin will automatically create contacts for your new users, and the contact can display anything from the profile plugin. Also it can display user articles and then you can add plugins for other things as well if you like. It always works much better for me than messing with the com_users profile.

+1


source







All Articles