We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37024
    • 14 Posts
    Hello all,

    I'm working on a site which supports user registrations and all registered user profiles are shown to public. Everything goes well using Login, Profile and etc. add-ons. The problem is with using friendly urls.

    Furls work fine, but only on resources. For user profiles my call is for example:
    www.domain.com/index.php?id=10&userId=5

    Furl converts this into:
    www.domain.com/profile.html?userId=5 (profile is the alias for the resource showing the profile of selected user)

    Is there any chance to show something like www.domain.com/user, or www.domain.com/user.html
    Thank you very much in advance for your support.

    I'm using Revo 2.2.4 pl

    Regards,
    Svetlyo
      valkovdesign.com
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      That looks like a good candidate for a plugin using the 'OnPageNotFound' event. Get the last part of the URI and look for a user with that name. Send forward to that user's profile. If it's still not found, process to the error page as usual.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 39932
        • 483 Posts
        Absolutely. There are a few ways to do this, depending on your needs.

        You may make a Resource with alias "user" and write a Snippet that checks if the current logged in user is a valid user (sanitizing MODx). Then you may get that user's profile.

        For further exploration: you may use @sottwell's suggestion and create a Plugin that fires on OnPageNotFound and accepts a parameter. (Such that http.//domain.tld/user/5). That parameter could grab the profile of that user ID when present, but when not present is the current user's profile. This is fairly simple to implement and I use such techniques in this tutorial. This tutorial does not directly apply to profiles, but is pretty easy to apply for just profiles.

        Both suggestions would require a single initial Resource named "user", and the Snippet to get the Profile information.
          Website: Extended Dialog Development Blog: on Extended Dialog
          Add-ons: AJAX Revolution, RO.IDEs Editor & Framework (in works) Utilities: Plugin Compatibility List
          Tutorials: Create Cross-Context Resources, Cross-Context AJAX Login, Template-Based Actions, Remove Extensions from URLs

          Failure is just another word for saying you didn't want to try. "It can't be done" means "I don't know how".
          • 37024
          • 14 Posts
          Thank you for the replies.

          Meantime I found easier way to implement this by use of UserUrls add-on by yoleg.

          After some modification I managed to achieve desired user profile address i.e. http://www.domain.com/username

            valkovdesign.com