Skip to:
Content
Pages
Categories
Search
Top
Bottom

Problems with active state menu for Homepage/Activity

  • Avatar of gian-ava
    gian-ava
    Participant

    @gian-ava

    I run single WP with BP Template Pack, and I set up Activity stream in Settings > Reading as Front page.

    So I got activity stream on my homepage.

    Unfortunately, I cannot get the active state fot the Home menu button to display, because the following statement doesn’t print class=”active” in the list item.

    <li <?php if ( is_front_page() || bp_is_front_page() || bp_is_page( BP_ACTIVITY_SLUG ) ) { echo 'class="active"'; } ?> id="home-nav"><a href="<?php echo get_settings('home'); ?>" alt="Home">Home</a></li>

    If I type http://cureuphoria.com/activity, than it prints it, because of the bp_is_page( BP_ACTIVITY_SLUG ) function.

    But http://cureuphoria.com, the homepage, is not recognized from is_front_page() and bp_is_front_page().

    Any hints?

Viewing 4 replies - 26 through 29 (of 29 total)
  • Avatar of gian-ava
    gian-ava
    Participant

    @gian-ava

    Thanks jivany! I see. Anyway, I’ve installed BP from the plugins panel in WP admin. So it is a released version.

    I am amazed that nobody else got this problem. If it’s in the release version, how can I be the only one having or complaining about this?

    Avatar of jivany
    jivany
    Participant

    @jivany

    @gian-ava: I think you found the problem in 1.2.3 and @21cdb just happened to find the problem when he was running the trunk version. Hence why I’ve been saying “raise a ticket”. ;)

    Everything isn’t guaranteed to be bug free and 100% working in any software. 90% of my “real life” job is fixing software bugs or explaining why we don’t need to fix them yet. ;)

    Avatar of gian-ava
    gian-ava
    Participant

    @gian-ava

    Thanks, jivany.

    I did not open a new ticket because one already existed: http://trac.buddypress.org/ticket/2260, so I contributed to that.

    It is so frustrating not to get something so basic to work. I try to figure out a workarond. Maybe If I say something like:

    If this page is not a wp page, blog, post, forums, groups, ect, by exclusion there will be only the homepage left, and I get to print the code for the highlight menu.

    And, the thing is that even thought I contributed to the ticket, I got no idea if it will be take into consideration for a next minor release. So I just have to sit there and passively hope.

    And I am not of that kind.

    ;-)

    Avatar of gian-ava
    gian-ava
    Participant

    @gian-ava

    Ok, here’s my TEMPORARY fix for highlighting (printing the class=”active”) the Home menu, waiting that the bp_is_front_page() fuction get fixed (if it ever will).

    The trick is simply to detect the homepage by its URL, with PHP.

    So, first create a function to know that get the main url (http://site.com).

    <?php
    // Define base URL (homepage)
    $homepage = "/";
    $currentpage = $_SERVER['REQUEST_URI'];
    ?>

    Than call the function as condition:

    <li <?php if($homepage==$currentpage) { echo 'class="active"'; } ?> id="home-nav"><a href="<?php echo get_settings('home'); ?>" alt="Home">Home</a></li>

    Just in case anybody else run into the same problem.

Viewing 4 replies - 26 through 29 (of 29 total)

You must be logged in to reply to this topic.