1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.4 How to Create a Dropdown Menu on Profiles

Discussion in 'Styling and Customization Questions' started by Amaury, Feb 22, 2015.

  1. Amaury

    Amaury Well-Known Member

    I wanted to create a new dropdown menu called Available Actions -- or something like that -- that would contain the following links:
    • Send Conversation
    • Report
    • Follow / Unfollow
    • Ignore / Unignore

    It would go to the left of the Moderator Tools dropdown menu.

    How can I accomplish this?

    Thanks!
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    Copy and paste the moderator tools drop down code, change the links and text to the ones you need.
     
    Amaury likes this.
  3. Amaury

    Amaury Well-Known Member

    Is this all of the relevant code for the Moderator Tools dropdown menu or am I missing something?

    Code:
    <xen:if hascontent="true">
                                <li><div class="Popup moderatorToolsPopup">
                                    <a rel="Menu">{xen:phrase moderator_tools}</a>
                                    <div class="Menu">
                                        <div class="primaryContent menuHeader"><h3>{xen:phrase moderator_tools}</h3></div>
                                        <ul class="secondaryContent blockLinksList">
                                        <xen:contentcheck>
                                            <xen:if is="{$canWarn}">
                                                <li><a href="{xen:link members/warn, $user}">{xen:phrase warn}</a></li>
                                            </xen:if>
                                            <xen:if is="{$canCleanSpam}">
                                                <li><a href="{xen:link spam-cleaner, $user, 'noredirect=1'}" class="deleteSpam OverlayTrigger">{xen:phrase spam}</a></li>
                                            </xen:if>
                                            <xen:if is="{$canViewIps}">
                                                <li><a href="{xen:link members/shared-ips, $user}" class="OverlayTrigger">{xen:phrase shared_ips}</a></li>
                                            </xen:if>
                                            <xen:if is="{$canBanUsers}">
                                                <xen:if is="{$user.is_banned}">
                                                    <li><a href="{xen:adminlink banning/users/lift, $user}">{xen:phrase lift_ban}</a></li>
                                                <xen:else />
                                                    <li><a href="{xen:adminlink banning/users/add, $user}">{xen:phrase ban}</a></li>
                                                </xen:if>
                                            </xen:if>
                                            <xen:if is="{$canEditUser}">
                                                <li><a href="{xen:link members/edit, $user}">{xen:phrase edit}</a></li>
                                            </xen:if>
                                        </xen:contentcheck>
                                        </ul>
                                    </div>
                                </div></li>
                            </xen:if>
     
  4. Chris D

    Chris D XenForo Developer Staff Member

    Looks like the mod tools menu, yeah.
     
    Amaury likes this.
  5. Amaury

    Amaury Well-Known Member

    So I sort of got it working, but I'm running into some trouble:
    1. I'm not seeing the Follow and Unfollow phrases in the member_view template, and this is what I get if I do template searches for {xen:phrase follow} and {xen:phrase unfollow}: account_following and member_follow for follow and member_list_item_follower and member_unfollow for unfollow, and I'm not seeing anything I can use there.
    2. Despite being before the Moderator Tools dropdown code, the Available Actions dropdown menu is appearing to the right of the Moderator Tools dropdown menu instead of to the left.

    Code:
                            <xen:if hascontent="true">
                                <li><div class="Popup moderatorToolsPopup">
                                    <a rel="Menu">{xen:phrase khflare_available_actions}</a>
                                    <div class="Menu">
                                        <div class="primaryContent menuHeader"><h3>{xen:phrase khflare_available_actions}</h3></div>
                                        <ul class="secondaryContent blockLinksList">
                                        <xen:contentcheck>
                                            <xen:if is="{$canReport}">
                                                <li><a href="{xen:link members/report, $user}" class="OverlayTrigger">{xen:phrase report}</a></li>
                                            </xen:if>
                                            <xen:if is="{xen:helper isIgnored, $user.user_id}">
                                                <li><a href="{xen:link members/unignore, $user}" class="FollowLink">{xen:phrase unignore}</a></li>
                                            <xen:elseif is="{$canIgnore}" />
                                                <li><a href="{xen:link members/ignore, $user}" class="FollowLink">{xen:phrase ignore}</a></li>
                                            </xen:if>
                                        </xen:contentcheck>
                                        </ul>
                                    </div>
                                </div></li>
                            </xen:if>
                          
                            <xen:if hascontent="true">
                                <li><div class="Popup moderatorToolsPopup">
                                    <a rel="Menu">{xen:phrase moderator_tools}</a>
                                    <div class="Menu">
                                        <div class="primaryContent menuHeader"><h3>{xen:phrase moderator_tools}</h3></div>
                                        <ul class="secondaryContent blockLinksList">
                                        <xen:contentcheck>
                                            <xen:if is="{$canWarn}">
                                                <li><a href="{xen:link members/warn, $user}">{xen:phrase warn}</a></li>
                                            </xen:if>
                                            <xen:if is="{$canCleanSpam}">
                                                <li><a href="{xen:link spam-cleaner, $user, 'noredirect=1'}" class="deleteSpam OverlayTrigger">{xen:phrase spam}</a></li>
                                            </xen:if>
                                            <xen:if is="{$canViewIps}">
                                                <li><a href="{xen:link members/shared-ips, $user}" class="OverlayTrigger">{xen:phrase shared_ips}</a></li>
                                            </xen:if>
                                            <xen:if is="{$canBanUsers}">
                                                <xen:if is="{$user.is_banned}">
                                                    <li><a href="{xen:adminlink banning/users/lift, $user}">{xen:phrase lift_ban}</a></li>
                                                <xen:else />
                                                    <li><a href="{xen:adminlink banning/users/add, $user}">{xen:phrase ban}</a></li>
                                                </xen:if>
                                            </xen:if>
                                            <xen:if is="{$canEditUser}">
                                                <li><a href="{xen:link members/edit, $user}">{xen:phrase edit}</a></li>
                                            </xen:if>
                                        </xen:contentcheck>
                                        </ul>
                                    </div>
                                </div></li>
                            </xen:if>
    Test.png

    What am I doing wrong?
     
  6. Chris D

    Chris D XenForo Developer Staff Member

    The items are floated to the right so the order will be reversed. Just move one above the other to change the order.

    Either those phrases will be in that template somewhere or they will be included via another template.

    Search all templates for the phrases you need maybe you'll find it.
     
  7. Amaury

    Amaury Well-Known Member

    Thanks, Chris! Got the order sorted, but I'm still having problems.

    The only things I see matching the phrases in the templates from the results above are:

    Code:
    <xen:hook name="account_following_controls">
        <dl class="ctrlUnit">
            <dt><label for="ctrl_users">{xen:phrase follow}:</label></dt>
            <dd>
                <input type="search" name="users" value="{$username}" results="0" placeholder="{xen:phrase name}..." class="textCtrl AutoComplete" id="ctrl_users" autofocus="autofocus" />
                <p class="explain">{xen:phrase separate_names_with_comma}</p>
            </dd>
        </dl>
        </xen:hook>
    In account_following for account/following.

    Code:
        <dl class="ctrlUnit submitUnit">
            <dt></dt>
            <dd><input type="submit" value="{xen:phrase follow}" class="button primary"    accesskey="s" /></dd>
        </dl>
    In member_follow, but I'm not sure where it's used. I tried changing something, though, and it didn't change anything on the profile page, so it's not used for that area.

    Code:
    <xen:include template="member_list_item">
        <xen:set var="$id">user_list_{$user.user_id}</xen:set>
        <xen:set var="$extraTemplate">
            <a href="{xen:link 'account/stop-following-confirm', '', 'user_id={$user.user_id}'}"
                class="UnfollowLink button smallButton"
                data-jsonUrl="{xen:link 'account/stop-following.json'}"
                data-userId="{$user.user_id}">{xen:phrase unfollow}</a>
        </xen:set>
    </xen:include>
    In member_list_item_follower for the member list.

    And:

    Code:
        <dl class="ctrlUnit submitUnit">
            <dt></dt>
            <dd><input type="submit" value="{xen:phrase unfollow}" class="button primary"    accesskey="s" /></dd>
        </dl>
    In member_unfollow, though like member_follow, I don't know where it's used.

    I'm not seeing anything like this (ifs, xen:link, etc.) for Follow and Unfollow:

    Code:
        <xen:if is="{$canReport}">
            <li><a href="{xen:link members/report, $user}" class="OverlayTrigger">{xen:phrase report}</a></li>
        </xen:if>
     
  8. Amaury

    Amaury Well-Known Member

    Solved it, @Chris D, thanks to @mike406!

    The follow / unfollow links work differently than the others, and that's why I didn't find anything when searching the templates for the relevant phrases. It was this line in the member_view template:

    Code:
    <xen:follow user="$user" title="" tag="li" />
     
  9. Amaury

    Amaury Well-Known Member

    @Chris D, because of the way our permissions are set up, when viewing a staff member's profile, only the Send Conversation and Follow / Unfollow links are available. However, when a staff member is viewing their own profile, there's nothing there due to the permissions setup, but the dropdown menu still shows. It's fine when a regular member is viewing their own profile since the Report link is still there.

    What conditional can I use to hide the Available Actions dropdown menu when a staff member is viewing their own profile? Thanks in advance!
     
  10. Chris D

    Chris D XenForo Developer Staff Member

    Probably something like:

    Code:
    <xen:if is="{$visitor.user_id} == {$user.user_id} AND {$visitor.is_staff}">
     
    Amaury likes this.
  11. Amaury

    Amaury Well-Known Member

    Replacing the ID part with the ID of the user group, correct?
     
  12. Chris D

    Chris D XenForo Developer Staff Member

    No, that's it.
     
    Amaury likes this.
  13. Amaury

    Amaury Well-Known Member

    Got it. Thanks, Chris. I'll give it a try in a little while and report back.
     
  14. Amaury

    Amaury Well-Known Member

    Tried to apply this, and I got this error: "The following templates contained errors and were not saved: member_view: 1) member_view - Line 260: Contentcheck tag found that was not a direct child of an if tag with hascontent attribute."

    I might have misplaced the closing <xen:if>.

    Code:
    <xen:if is="{$visitor.user_id} == {$user.user_id} AND {$visitor.is_staff}">
                                <li><div class="Popup moderatorToolsPopup">
                                    <a rel="Menu">{xen:phrase khflare_available_actions}</a>
                                    <div class="Menu">
                                        <div class="primaryContent menuHeader"><h3>{xen:phrase khflare_available_actions}</h3></div>
                                        <ul class="secondaryContent blockLinksList">
                                        <xen:contentcheck>
                                            <xen:if is="{$canStartConversation}">
                                                <li><a href="{xen:link conversations/add, '', 'to={$user.username}'}">{xen:phrase start_conversation}</a></li>
                                            </xen:if>
                                            <xen:follow user="$user" title="" tag="li" />
                                            <xen:if is="{xen:helper isIgnored, $user.user_id}">
                                                <li><a href="{xen:link members/unignore, $user}" class="FollowLink">{xen:phrase unignore}</a></li>
                                            <xen:elseif is="{$canIgnore}" />
                                                <li><a href="{xen:link members/ignore, $user}" class="FollowLink">{xen:phrase ignore}</a></li>
                                            </xen:if>
                                            <xen:if is="{$canReport}">
                                                <li><a href="{xen:link members/report, $user}" class="OverlayTrigger">{xen:phrase report}</a></li>
                                            </xen:if>
                                        </xen:contentcheck>
                                        </ul>
                                    </div>
                                </div></li>
                            </xen:if>
                            </xen:if>
     
  15. Chris D

    Chris D XenForo Developer Staff Member

    You would need to remove the <xen:contentcheck> and </xen:contentcheck> if there is no <xen:if hascontent="true"> line.

    Looks like you might have an extra </xen:if> at the bottom too that you don't need.
     
    Amaury likes this.
  16. Amaury

    Amaury Well-Known Member

    Thanks, I'll have a look later. I've got something to do.

    I think that's the closing one for the very first part of the code for the menus:

    Code:
    <xen:if hascontent="true">
                                <li><div class="Popup moderatorToolsPopup">
                                    <a rel="Menu">{xen:phrase moderator_tools}</a>
     
  17. Amaury

    Amaury Well-Known Member

    Okay, so I got it to save, Chris, but the menu didn't disappear.
     
  18. Amaury

    Amaury Well-Known Member

    @Chris D, I just discovered that it had the unfortunate opposite effect of what I wanted. On profiles other than your own, the Available Actions dropdown menu is hidden even though there are items in it.

    I probably did something wrong again.
     
  19. Amaury

    Amaury Well-Known Member

    Still looking for help with the above, @Chris D. Whenever you have some spare time, though. No rush. :)

    @Nights was going to help, but he's been busy and hasn't been on since late March and @mike406 has been on reserve since mid-March for emergencies only due to health issues.
     
  20. Amaury

    Amaury Well-Known Member

    @Chris D, just wanted to let you know we got this solved yesterday. @Nights modified the conditional you provided a little:

    Code:
    <xen:if is="{$visitor.user_id} != {$user.user_id}">
     

Share This Page