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

XF 1.1 how to hide the "What's New" Tab from visitors?

Discussion in 'XenForo Questions and Support' started by erich37, Jan 24, 2012.

  1. erich37

    erich37 Well-Known Member

    I would like to hide the "What's New"-Tab and the "Search Forums"-Tab in the navigation-bar from visitors (unregistered users).
    Only logged-in members should see this Tab.

    Or probably better to have a separate page which says "You must Sign-up or Log-in" to access the Forum", when a visitor clicks on those Tabs?


    Could you please let me know of how to do this?

    Thanks!
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    erich37 likes this.
  3. erich37

    erich37 Well-Known Member

    I have hidden the "Search Forums" via the ACP and also hidden the "What's New"-Tab from guests as per your instruction.

    However it seems I am doing something wrong, as the drop-down-box still appears at the "Home"-Tab. But this drop-down-arrow only shows the text for "Quick Links".
    Is there a way to also hide this (empty) drop-down-box from visitors?

    remove_navigation_drop_down.gif

    Is there a way to hide all Tabs in the Sub-Nav-Bar and also this "Quick-Links" drop-down?
    I would like to only show the 3 Main Tabs "Home", "Members", "Help", but without the Sub-Tabs underneath them.

    But I would like to keep the default design of the light-blue background-color of the Sub-Nav-Bar.

    Please anyone help, I am willing to send a donation for help!
     
  4. Brogan

    Brogan XenForo Moderator Staff Member

    The Home tab doesn't have a drop down in the default style.
    Do you have any add-ons installed? I suspect it comes from that.
     
  5. erich37

    erich37 Well-Known Member

    my "Home"-Tab is actually the "Forums"-Tab. I have just re-named "Forums" to "Home" in the phrases.........
    I have no add-ons installed and using the default XF-style.

    Could you please help me to hide all the Tabs in the Sub-Nav-Bar? I could not figure out where to put the code for hiding those Sub-Tabs from visitors.

    Thank you!
     
  6. steel_curtain

    steel_curtain Well-Known Member

    Edit: Scratch that, just realized you want to do it as a conditional. I'll see what I can come up with.
     
    erich37 likes this.
  7. erich37

    erich37 Well-Known Member

    just to make it clear what I am talking about: :)

    - I only want to show the 2 Main Tabs named "Forums" and "Members" to visitors who are not logged-in (in my case I have re-named "Forums" to "Home" via phrases, but this should not make a difference).
    - Logged-in Members should see ALL Tabs (as per XF default).

    So literally I do not want to show the "What's New", "Recent Activitiy" and "Current Visitors" Sub-Tabs and also not show all the "Help"-Tabs and Sub-Tabs to visitors who are not logged-in.

    I will put a Link for the "Help" (path: /help/terms) into the Footer and have it there to be accessible and visible for visitors.

    The drop-down-fields should not open-up, as they will just show the text "Quick Links" for visitors (not logged-in).

    Appreciate all your help! My donation is waiting if you can come up with a solution.
    Thanks!
     
  8. steel_curtain

    steel_curtain Well-Known Member

    Try this out, it involves template edits, but since extra.css can't use conditionals I don't see any other way. You'll need to modify the navigation template.

    The edits below were to the forums tab.

    Code:
    <!-- forums -->
            <xen:if is="{$tabs.forums}">
                <li class="navTab forums {xen:if $tabs.forums.selected, 'selected', 'Popup PopupControl PopupClosed'}">
     
                <xen:if is="{$visitor.user_id}">
                    <a href="{$tabs.forums.href}" class="navLink">{$tabs.forums.title}</a>
                    <a href="{$tabs.forums.href}" class="SplitCtrl" rel="Menu"></a>
       
                    <div class="{xen:if {$tabs.forums.selected}, 'tabLinks', 'Menu JsOnly tabMenu'}">
                        <div class="primaryContent menuHeader">
                            <h3>{$tabs.forums.title}</h3>
                            <div class="muted">{xen:phrase quick_links}</div>
                        </div>
                        <ul class="secondaryContent blockLinksList">
                        <xen:hook name="navigation_tabs_forums">
                            <xen:if is="{$visitor.user_id}"><li><a href="{xen:link 'forums/-/mark-read', $forum, 'date={$serverTime}'}" class="OverlayTrigger">{xen:phrase mark_forums_read}</a></li></xen:if>
                            <xen:if is="{$canSearch}"><li><a href="{xen:link search, '', 'type=post'}">{xen:phrase search_forums}</a></li></xen:if>
                            <xen:if is="{$visitor.user_id}"><li><a href="{xen:link 'watched/threads'}">{xen:phrase watched_threads}</a></li></xen:if>
                            <li><a href="{xen:link 'find-new/threads'}">{xen:phrase whats_new}</a></li>
                        </xen:hook>
                        </ul>
                    </div>
                <xen:else/>                   
                    <a href="{$tabs.forums.href}" class="navLink">{$tabs.forums.title}</a>
                    <div class="tabLinks"></div>
                </xen:if>
                </li>
            </xen:if>
    
    For the members tab use this.

    Code:
    <!-- members -->
            <xen:if is="{$tabs.members}">
                <li class="navTab members {xen:if $tabs.members.selected, 'selected', 'Popup PopupControl PopupClosed'}">
         
               <xen:if is="{$visitor.user_id}">
                    <a href="{$tabs.members.href}" class="navLink">{$tabs.members.title}</a>
                    <a href="{$tabs.members.href}" class="SplitCtrl" rel="Menu"></a>
             
                    <div class="{xen:if {$tabs.members.selected}, 'tabLinks', 'Menu JsOnly tabMenu'}">
                        <div class="primaryContent menuHeader">
                            <h3>{$tabs.members.title}</h3>
                            <div class="muted">{xen:phrase quick_links}</div>
                        </div>
                        <ul class="secondaryContent blockLinksList">
                        <xen:hook name="navigation_tabs_members">
                            <li><a href="{xen:link members}">{xen:phrase registered_members}</a></li>
                            <li><a href="{xen:link online}">{xen:phrase current_visitors}</a></li>
                            <xen:if is="{$xenOptions.enableNewsFeed}"><li><a href="{xen:link recent-activity}">{xen:phrase recent_activity}</a></li></xen:if>
                        </xen:hook>
                        </ul>
                    </div>
                <xen:else/>                                
                    <a href="{$tabs.members.href}" class="navLink">{$tabs.members.title}</a>
                    <div class="tabLinks"></div>
                </xen:if>
                </li>
            </xen:if>
    
    For the help tap use this.
    Code:
    <!-- help -->
     
            <xen:if is="{$tabs.help}">
                <li class="navTab help {xen:if $tabs.help.selected, 'selected', 'Popup PopupControl PopupClosed'}">
             
                <xen:if is="{$visitor.user_id}">
                    <a href="{$tabs.help.href}" class="navLink" rel="help">{$tabs.help.title}</a>
                    <a href="{$tabs.help.href}" class="SplitCtrl" rel="Menu"></a>
     
                    <div class="{xen:if {$tabs.help.selected}, 'tabLinks', 'Menu JsOnly tabMenu'}">
                        <div class="primaryContent menuHeader">
                            <h3>{$tabs.help.title}</h3>
                            <div class="muted">{xen:phrase quick_links}</div>
                        </div>
                        <ul class="secondaryContent blockLinksList">
                        <xen:hook name="navigation_tabs_help">
                            <li><a href="{xen:link help/smilies}">{xen:phrase smilies}</a></li>
                            <li><a href="{xen:link help/bb-codes}">{xen:phrase bb_codes}</a></li>
                            <li><a href="{xen:link help/trophies}">{xen:phrase trophies}</a></li>
                        </xen:hook>
                        </ul>
                    </div>
                <xen:else/>                              
                    <div class="tabLinks"></div>
                </xen:if>
                </li>
            </xen:if>
     
    Alien, erich37 and Fuhrmann like this.
  9. erich37

    erich37 Well-Known Member

    Many thanks!

    I will try this tomorrow as I need some sleep now.
    I will reply back to you......:)
     
  10. erich37

    erich37 Well-Known Member

    wow, you are talented!
    this works nice, however when someone knows the URL, he can still access the "Recent Activity" and also the "Current Visitors" via the following URLs:

    http://www.domain.com/recent-activity

    http://www.domain.com/online

    Is there a way to really hide this from visitors (when not logged-in), even when they get to the URL via search-engines?

    I do not want to hide the "Member-List", but does this code from Brogan help in some way in order to achieve this?
    http://xenforo.com/community/thread...ber-list-a-usergroup-option.8941/#post-184226
     
  11. borbole

    borbole Well-Known Member

    At the RecentActivity.php file, find this code:

    PHP:
    $this->_assertNewsFeedEnabled();
    and add the following code above it:

    PHP:
    $this->_assertRegistrationRequired();
    This will block the Recent Activity page for guests if they go to it via the url.

    Whereas to block the online page from guests, at the Online.php file, find this code:

    PHP:
    $sessionModel $this->_getSessionModel();
    And above it add the same code like with the other file. i.e.:

    PHP:
    $this->_assertRegistrationRequired();
    That ought to do it. Both files that are to be edited can be found at /your_forum_folder/library/XenForo/ControllerPublic. Hope it helps.
     
    AndreaMarucci and erich37 like this.
  12. erich37

    erich37 Well-Known Member

    Many thanks borbole! Great Help!!!!!

    It works like a charm!

    Could you please give me a quick hint of how to do the same with the "What's New" page?

    Would this be the same code in the "FindNew.php" file? But where to place the code?

    Appreciate your help!
     
    borbole likes this.
  13. borbole

    borbole Well-Known Member

    Yes, that would be the same code at the FindNew.php file. Add it right after the first function definition in there. i.e. below this code:

    PHP:
    public function actionThreads()
    {
     
     
    erich37 likes this.
  14. erich37

    erich37 Well-Known Member

    works fine, thanks again!
     
    borbole likes this.
  15. borbole

    borbole Well-Known Member

    You are welcome.
     
    WatchMan likes this.
  16. erich37

    erich37 Well-Known Member

    Dear borbole,

    I would like to hide the "Members Tab" and also the "Members Page" (Member List) for visitors. So that it shows "Registration Required" when a visitor visits the URL "domain.com/members"
    Is it possible to do this with this code? Do you know which file to edit and how?



    Would you mind helping with an advise of how to do this?

    Many thanks!
     
  17. borbole

    borbole Well-Known Member

    At the Members.php file find this code:

    PHP:
    public function actionIndex()
        {
    and below it add the code:

    PHP:
    $this->_assertRegistrationRequired(); 
     
  18. Beanjam

    Beanjam Active Member

    Does anybody know a way to also stop unconfirmed users from viewing these pages?
     
  19. Digital Doctor

    Digital Doctor Well-Known Member

  20. Beanjam

    Beanjam Active Member

    Thanks. I've already hidden the tabs and sidebars using those methods. But I'm not sure how to also hide them from members who have registered but not yet confirmed.
     
    erich37 likes this.

Share This Page