We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40404
    • 21 Posts
    Revo 2.3.1, I'm trying to customize the userNav menu to display the user's fullname, not username. I can update the Menu Icon:

    <span id="user-avatar">{$userImage}</span> <span id="user-username">{$username}</span>


    But it appears I would need to set an additional placeholder from what is set in the default header.php controller. What's the correct way to do this so I don't have to modify core?
      • 3749
      • 24,544 Posts
      I think this would do it:

      [[+modx.user.id:userinfo=`fullname`]]


      You might have to call it uncached:

      [[!+modx.user.id:userinfo=`fullname`]]
        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
        • 40404
        • 21 Posts
        Using [[+modx.user.id:userinfo=`fullname`]] just displays the unprocessed tag.

        Using {[[+modx.user.id:userinfo=`fullname`]]} breaks the page.
          • 3749
          • 24,544 Posts
          How about this?

          [[!+modx.user.id:userinfo=`fullname`]]


          Is userNav an extra? I couldn't find it. It might help if I could see the code that's doing the processing.

          If this is always for the current user, a custom snippet might do it. Put this where you want the fullname:

          [[!GetFullname]]


          Create a snippet called GetFullname with this code:

          <?php
          /*GetFullname snippet */
          $profile = $modx->user->getOne('Profile');
          if ($profile) {
              return $profile->get('fullname');
          }
          /* Fall back to username if the user has no profile */
          return $modx->user->get('username');


          If that works, let me know and I'll give you a faster version.
            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
            • 40404
            • 21 Posts
            Sorry, not sure how to correctly refer to it. It's part of the new Manager menu in 2.3.

            /manager/templates/default/header.tpl has:
            <ul id="modx-user-menu">
                {* eval is used here to support nested variables *}
                {eval var=$userNav}
            </ul>


            $userNav seems to be build from the database table, which also has a UI under the "Admin" (gear) menu->menus. The "icon" field for the "user" item has:
            <span id="user-avatar">{$userImage}</span> <span id="user-username">{$username}</span>


            And the {$username} placeholder is being set in /manager/controllers/default/header.php:
            /**
             * Set a bunch of placeholders to be used within Smarty templates
             *
             * @return void
             */
            public function setPlaceholders()
            {
                $placeholders = array(
                    'username' => $this->modx->getLoginUserName(),
                    'userImage' => $this->getUserImage(),
                );
            
                $this->controller->setPlaceholders($placeholders);
            }


            I tried your suggestions but it looks like that part of the manager UI isn't processing MODx tags at all.
              • 4172
              • 5,888 Posts
              this should work, but would be overriden with an upgrade:

                  /**
                   * Set a bunch of placeholders to be used within Smarty templates
                   *
                   * @return void
                   */
                  public function setPlaceholders()
                  {
                      $profile = $this->modx->user->getOne('Profile');
                      
                      $placeholders = array(
                          'username' => $profile->get('fullname'),
                          'userImage' => $this->getUserImage(),
                      );
              
                      $this->controller->setPlaceholders($placeholders);
                  }
              
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 40404
                • 21 Posts
                Yeah, I wanted a way that didn't modify core. Is there no way to set an extra placeholder?
                  • 4172
                  • 5,888 Posts
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 40404
                    • 21 Posts
                    I actually tried this, copying header.php to /manager/controllers/custom/header.php, but when I switch the manger_theme system setting to custom, the whole manager "breaks," as if there's no CSS. This happens even if the header.php is unmodified. The RTFM says I should be able to copy individual files, but is there a minimum set that 2.3 requires?