• How can i do that?#

  • bowkilled Reply #1, 7 months ago

    Reply
    Hi, im wondering how to make a dynamic user listing, lets say we use Peoples to list the users then we use Login to make the profile of the user, now we want to view that users profile page, how can i do that? There are no built-in function for that as far as ive seen..
    Would be gratefull with any answer thanks.


  • BobRay Reply #2, 7 months ago

    Reply
    The Login package includes a Profile snippet that should do what you want: http://rtfm.modx.com/display/ADDON/Login.Profile


  • bowkilled Reply #3, 7 months ago

    Reply
    I got that allready but im wondering how to do something like a member list and link to the user's profile
    As early MODX user i know that WebloginPE had a built in function like this..
    look url: bowkilled123 i would like to use either the user id "" or "" in the url of the profile page.
    How to do this?


  • BobRay Reply #4, 7 months ago

    Reply
    I'm afraid that link is dead, so I don't know exactly what you want, but you should be able to put a placeholder for the ID in the link of the Tpl chunk used by Peoples. If the link always forwards users to the same page, you could have a snippet there that grabs the $_GET parameter and sends it to the Profile snippet using $modx->runSnippet('Profile').


  • bowkilled Reply #5, 7 months ago

    Reply
    Hi again Bob, could you give me some more ideas of building this thing?
    Lets say this stuff below is my "wished" webpage with users:

    Memberlist

    Username: bowkilled123 View my profile

    Username: user2 View my profile

    Username: user35 View my profile

    This is the default code / snapped out from a paragraph in the Profile.php located at core/components/login/controllers/web
        /**
         * Get the specified or active user
         * @return boolean|modUser
         */
        public function getUser() {
            $user = $this->getProperty('user',false,'isset');
    
            /* verify authenticated status if no user specified */
            if (empty($user) && !$this->modx->user->hasSessionContext($this->modx->context->get('key'))) {
                $this->user = false;
            }
            /* specifying a specific user, so try and get it */
            if (!empty($user)) {
                $username = $user;
                $userNum = (int)$user;
                $c = array();
                if (!empty($userNum)) {
                    $c['id'] = $userNum;
                } else {
                    $c['username'] = $username;
                }
                $this->user = $this->modx->getObject('modUser',$c);
                if (!$this->user) {
                    $this->modx->log(modX::LOG_LEVEL_ERROR,'Could not find user: '.$username);
                    $this->user = false;
                }
            /* just use current user */
            } else {
                $this->user =& $this->modx->user;
            }
            return $this->user;
        }
    }
    return 'LoginProfileController';





  • BobRay Reply #6, 7 months ago

    Reply
    Here's what I'm suggesting (tested):

    On the user list page:

    [[Peoples? &limit=`5000` &tpl=`MyPeoplesTplChunk`]]


    MyPeoplesTplChunk (replace 99 with the ID of the page that shows the profile):

    <li class="[[+cls]]">[[+username]] <a href="[[~99? &userId=`[[+id]]`]]">See My Profile</a></li>


    On the page that shows the profile:

    [[Profile? &user=`[[!GetUserId]]`]]
    
    <p>Username: [[+username]]</p>
    <p>email: [[+email]]</p>
    
    




    GetUserId snippet:

    <?php
    /*GetUserId snippet */
    return $_GET['userId'];


    Be sure both the Peoples package and the Login package are installed.


  • bowkilled Reply #7, 7 months ago

    Reply
    Hi again Bob, im sorry to say that the code you posted doesnt work. But lets try get it to work, maybe there are some more hard-core modx coders here on the community forums.

    Anyhow I am testing some code that i've written some hour ago. Will post it later if it works.

    If we succeed with this it will become a great success because it is an improvement of an snippet that doesnt have that feature built in allready. Thanks.


  • BobRay Reply #8, 7 months ago

    Reply
    OK, fixed two minor problems. &userId in the Profile tag should be &user, and the page that shows the profile needs some placeholders to show the fields. Corrected above. It works now.


  • bowkilled Reply #9, 7 months ago

    Reply
    Works fantastic, great stuff Bob. Thanks for the help.


  • BobRay Reply #10, 7 months ago

    Reply
    My Pleasure.