Add user's display name to owner-block and profile content menus?

This one is costing me hair... LOL. I was working on this a couple weeks ago, then I left for vacation, and now have no idea which file(s) I was editing. I am simply trying to add the members 'display name' before the category on the owner-block/profile-content-menu's. For example... Johnny's Photos, Johnny's Blogs, Johnny's Wire Posts, you get the point. Anyway, any clues as to which file(s) I was editing?

  • I think I was changing one line in each plugin that registers to the owner block, don't believe it was the language file though.

  • look in the start menu at the FUNCTION....owner_block_menu

  • DOHHH!!!  ~(8(l) 

    You've come to the rescue once again! Thank you, sir.

  • function blog_owner_block_menu($hook, $type, $return, $params) {
        if (elgg_instanceof($params['entity'], 'user')) {
            $url = "blog/owner/{$params['entity']->username}";
            $item = new ElggMenuItem('blog', elgg_echo('blog'), $url);
            $return[] = $item;
        } else {
            if ($params['entity']->blog_enable != "no") {
                $url = "blog/group/{$params['entity']->guid}/all";
                $item = new ElggMenuItem('blog', elgg_echo('blog:group'), $url);
                $return[] = $item;
            }
        }

     

      $item = new ElggMenuItem('blog', elgg_echo('blog'), $url);

    the elgg_echo is where you would do it i believe

  • I can get the display name to appear when I close $params early, like below. But I can't get it to include the language call and url. I've tried... $item = new ElggMenuItem('blog', elgg_echo(($params['entity']->name), 'blog:title:user_blogs', $url); AND $item = new ElggMenuItem('blog', elgg_echo($params['entity']->name, 'blog:title:user_blogs', $url); But they throw errors. Any ideas?

     

     

     

    function blog_owner_block_menu($hook, $type, $return, $params) {

        if (elgg_instanceof($params['entity'], 'user')) {

            $url = "blog/owner/{$params['entity']->username}";

            $item = new ElggMenuItem('blog', elgg_echo($params['entity']->name), 'blog:title:user_blogs', $url);

            $return[] = $item;

        } else {

            if ($params['entity']->blog_enable != "no") {

                $url = "blog/group/{$params['entity']->guid}/all";

                $item = new ElggMenuItem('blog', elgg_echo('blog:group'), $url);

                $return[] = $item;

  • $params['entity']->username

     

  • That would just switch it from 'display name' to 'user name'. I'm having trouble figuring out how to close the $params without excluding my language file from the button (e.g. "\'s Blogs") and making the language file become the url (www.mydomain.com/elgg/blog:title:user_blogs). Sorry for not being clearer last night. My eyes were growing heavy. Thanks for all your help, as always. :)

  • I have my code currently as below, which coreected the url issue, and shows the members 'display name' as desired, but it's still not calling the language file. I suspect I am improperly using elgg_echo. How do you join the two calls in elgg_echo, or can I? I've tried creating two elgg_echo's but couldn't seem to get that to call both, either. Any help as to what I'm doing wrong?

     

    function blog_owner_block_menu($hook, $type, $return, $params) {

        if (elgg_instanceof($params['entity'], 'user')) {

            $url = "blog/owner/{$params['entity']->username}";

            $item = new ElggMenuItem('blog', elgg_echo($params['entity']->name, 'blog:title:user_blogs'), $url);

            $return[] = $item;

        } else {

            if ($params['entity']->blog_enable != "no") {

                $url = "blog/group/{$params['entity']->guid}/all";

                $item = new ElggMenuItem('blog', elgg_echo('blog:group'), $url);

                $return[] = $item;

  • I achieved my goal with the following code. It feels hacky, though. I couldn't get the language file to work. Any insights?

     

    if (elgg_instanceof($params['entity'], 'user')) {

            $url = "blog/owner/{$params['entity']->username}";

            $item = new ElggMenuItem('blog', elgg_echo("{$params['entity']->name}'s Blogs"), $url);

            $return[] = $item;

        } else {

            if ($params['entity']->blog_enable != "no") {

                $url = "blog/group/{$params['entity']->guid}/all";

                $item = new ElggMenuItem('blog', elgg_echo('blog:group'), $url);

                $return[] = $item;

  • I think it is something like this
    <?php

    echo elgg_echo('blog_or_name_of_plugin:message_name_you_wrote_in_lang_file');

    ?> 

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking