We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37686
    • 94 Posts
    when i call peoples snippet in my document template, it refers to my peoples Template... this peoples template looks like this:

    <table class="teachers-tabel">
    <tr>    
        <td>photo</td>
        <td>[[+photo:notempty=`<img src="[[+photo]]" alt="[[+username]]"/>`:empty=`<img src="assets/images/no-picture.jpg" alt="no picture"/>`]]</td>
    </tr>
    <tr>
        <td>Name:</td>
        <td class="teacher-cel">[[+fullname]]</td>
    </tr>
    </tr>
    <tr>
        <td>Teaching:</td>
        <td class="teacher-cel">[[+extended.instrument]]</td>
    </tr>
    <tr>
      <td>Teaches<br>also:</td>
      <td>[[+extended.instrument2]]</td>
    </tr>
    <tr>
      <td>More</td>
      <td>[[+id]]</td>
    </tr>
    </table>


    in this table you see all the teachers.. however, i would like to approach the teachers seperatly from within this template, so they go to the personal page of the specific teacher..
    i know i can arange is with php GET, but i dont like to ruin my url with that.

    I guess i need to use the id of the teachers right?

    thanx for time!!

    This question has been answered by stevebravo. See the first response.

      • 3749
      • 24,544 Posts
      If I'm understanding you, you should be able to use the same Tpl chunk, but with the Profile snippet rather than Peoples and the &user property set to the ID or username of the person.



      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 37686
        • 94 Posts
        thanx.. you are right...
        but now i would like to add the users id into the &user of the Profile snippet.

        i made something like this, but it does not work smiley

        if($_GET['id'] != ''){
           $id = $_GET['id'];
           print $id;
           print '
                  [[!Profile? &user=`.$id.` &prefix=`user.`]]
                 ';
           print '[[+user.usersname]]';
        
        }
        


        how can i add the $id into the user property?
        • discuss.answer
          • 37686
          • 94 Posts
          fixed!

              [[!Profile? &user=`'.$id.'` &prefix=`user.`]]


          thanx bob for you spare time
            • 3749
            • 24,544 Posts
            Do you want the ID of the currently logged-in user? If so, that would be:

            $id = $modx->user->get('id');

            You also need to correct the typo in the last line (it's 'username', not 'usersname') and you shouldn't use print, you should return a variable instead -- you're also missing a single quote before &prefix.

            Try this:

            <?php
            $output = 'No User Logged In';
            if ($modx->user->get('username') != '(anonymous)') {
                $id = $modx->user->get('id');
                $output = '[[!Profile? &user=`' . $id . '` &prefix=`user.`]]';
                $output .= '[[+user.username]]';
            }
            return $output;
            



            ------------------------------------------------------------------------------------------
            PLEASE, PLEASE specify the version of MODX you are using.
            MODX info for everyone: http://bobsguides.com/modx.html
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting