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

selectedTab question

Discussion in 'XenForo Development Discussions' started by Mythotical, Oct 10, 2010.

  1. Mythotical

    Mythotical Well-Known Member

    I am creating an addon that creates an additional page that is viewed from the forum perspective, how would I tell this page to select the Forums tab when viewing the page?

    I have tried many ways but I am not sure how to do this specifically. This would also help with another addon I'm building.
     
  2. Shadab

    Shadab Well-Known Member

    In your route prefix class, the 3rd parameter (majorSection) for the getRouteMatch() method should be 'forums'.
    That should work. :)

    PHP:
        /**
         * Gets a route match object.
         *
         * @param string $controllerName
         * @param string|false $action
         * @param string $majorSection
         * @param string $minorSection
         *
         * @return XenForo_RouteMatch
         */
     
    Mikey likes this.
  3. Mythotical

    Mythotical Well-Known Member

    Ok thanks Shadab, what would it be for the home tab to be selected then?
     
  4. Shadab

    Shadab Well-Known Member

    'forums', 'members' and 'help' selects the corresponding tab.
    But strangely, passing 'home' as the parameter doesn't select the Home tab. :confused:

    *Diving into the source to see what's happening...

    EDIT:
    Looks like it's the only tab that can't be selected.
     
  5. Mythotical

    Mythotical Well-Known Member

    Hehe, I've been swimming around the source for the last 24 hours and cannot find why the home tab can't be selected. I created this thread just in case I was missing something.
     
  6. g0rn

    g0rn Well-Known Member

    In template called navigation you can see that Home tab doesn't have conditions that may make it selected unlike other tabs.
     
  7. Shadab

    Shadab Well-Known Member

    Yeah. The home tab isn't a tab per-se.

    Would've been great if the XenForo_Dependencies_Public::_getNavigationContainerParams() method & navigation template contained proper logic for selecting the home tab, even though it won't be used by the any XF core feature anytime soon.

    Now who's posting the bug/enhancement report? :p
     
  8. Luciano

    Luciano Member

    I havent looked at the code yet..(starting next week) but, just a thought, i suppose that home is the default tab?
    i.e. if no tab is selected, the home tab is selected by default..
     
  9. Mythotical

    Mythotical Well-Known Member

    Ok I found a work around, I'll comment out the tab in the template and just add an extra tab via the event listener.
     
  10. Mythotical

    Mythotical Well-Known Member

    Tested and that didn't even work.
     
  11. Mythotical

    Mythotical Well-Known Member

    I ran into another problem. I managed to get my own Home tab in there but when you view a page it says: Home > Home > Page

    So I am trying to figure out a work around for that but coming up empty handed. Any ideas?
     
  12. Luciano

    Luciano Member

    Well when I want my own home tab i just define in options (where you input forum url and homepage url) the link to that page, and when i click the hometab it goes to my page.
    But maybe we are talking about different things.
     
  13. Mythotical

    Mythotical Well-Known Member

  14. Luciano

    Luciano Member

    Well I had a look, and figured that the home tab is nothing else than a html element in a template and not generated..
    I read in another thread, that Kier was going to find a way to make home tab a "real" tab

    For the moment, I can just remember the way we did changes like that in vbulletin when there was no template_hook around. (it was not very elegant)

    We simply replaced the bit of code or the phrase in the template cache with str_replace or str_replace_callback. (I do not know if there is something similar to template_cache in xf. But if yes, you could just replace whats between <!-- home --> and <!-- forums --> in template navigation with the code of a new tab.

    (I''m just writing what goes through my head as you said you were looking for "Ideas")
     
  15. Mythotical

    Mythotical Well-Known Member

    Yeah tried that but I will probably just have to keep it the way I have it for now until Kier releases a new version that has Home tab as its own tab. So php file altering will be required for my portal system.
     

Share This Page