Skip to:
Content
Pages
Categories
Search
Top
Bottom

Old custom sub_nav items no longer work in groups….chasing it all down


  • abutterworth
    Member

    @abutterworth

    A few points:
    My WP is the latest and I’m running all of this on a subdomain
    I have buddypress template pack; cubepoints; buddypress registration groups;and YARRPP, simple tags.
    I have dramatically altered the default theme
    And modified the core files as outlined below:

    OLD 1.2 – in: bp-core-templatetags.php
    line 1847
    I added this function
    function bp_is_group_stock_quote() {
    global $bp;
    if ( BP_GROUPS_SLUG == $bp->current_component && ‘stock-quote’ == $bp->current_action )
    return true;
    return false;
    }

    OLD 1.2 in: bp-groups.php
    line 215
    I added:
    bp_core_new_subnav_item( array( ‘name’ => __( ‘Stock Quote’, ‘buddypress’ ), ‘slug’ => ‘stock-quote’, ‘parent_url’ => $group_link, ‘parent_slug’ => $bp->groups->slug, ‘screen_function’ => ‘groups_screen_group_stock’, ‘position’ => 80, ‘user_has_access’ => $bp->groups->current_group->user_has_access, ‘item_css_id’ => ‘stock’ ) );

    and this added my own templates to the item-nav in my groups

    In Buddypress 1.5 none of it works. This site is in development but my deadline is loooming.

    NEW 1.5 in: bp-core-template.php
    line 1383
    I added:

    function bp_is_group_stock_quote() {
    if ( bp_is_groups_component() && bp_is_current_action( ‘stock-quote’ ) )
    return true;
    return false;
    }

    But I can’t figure out what the comparable action is to what I setup in bp-groups.php. I’m sorry I am not a programmer and the threads I have read don’t make sense to me and I have chased my own tail for hours now trying to figure this out.

    Please tell me how I add back custom sub-nav items to my groups.
    It used to look like this – i added lots of extra pages and everything was working and I was almost done after weeks of no sleep!
    Home > Admin > Send Invites > Forum > Stock Quote > Projects > Third Party Coverage > Interviews > Contact > Members
    Thanks so much in advance!! I do appreciate an improved product just wish my skills were better to smooth it all out.

    Andrea

Viewing 9 replies - 1 through 9 (of 9 total)

  • abutterworth
    Member

    @abutterworth

    Hi update:
    I’ve found bp-group-loader.php where I was able to define $sub_nav[] items and they are indeed displaying on the site.
    I have defined the stock-quote item as follows:
    $sub_nav[] = array(
    ‘name’ => __( ‘Stock Quote’, ‘buddypress’ ),
    ‘slug’ => ‘stock-quote’,
    ‘parent_url’ => $group_link,
    ‘parent_slug’ => $this->current_group->slug,
    ‘screen_function’ => ‘groups_screen_group_stock_quote’,
    ‘item_css_id’ => ‘stock’,
    ‘position’ => 50,
    ‘user_has_access’ => $this->current_group->user_has_access
    );

    But I get this error when I try to click on the link:
    First argument is expected to be a valid callback, ‘groups_screen_group_stock_quote’ was given in /home/resource/public_html/dev/wp-includes/plugin.php on line 405

    dev URI is:
    http://dev.resourceclips.com

    Any thoughts?


    abutterworth
    Member

    @abutterworth

    SO I didn’t receive any answers on this but I did manage to struggle my way through and I will leave the solution here for those with the same question.

    To add sub_nav links in buddypress 1.5 groups do the following:
    1) bp-core-template.php
    register the groups
    ///////////////
    function bp_is_group_stock_quote() {
    if ( bp_is_groups_component() && bp_is_current_action( ‘stock-quote’ ) )
    return true;
    return false;
    }
    //////////////////

    2) bp-group-loader.php
    define the subnav item:
    /////////////////
    $sub_nav[] = array(
    ‘name’ => __( ‘Stock Quote’, ‘buddypress’ ),
    ‘slug’ => ‘stock-quote’,
    ‘parent_url’ => $group_link,
    ‘parent_slug’ => $this->current_group->slug,
    ‘screen_function’ => ‘groups_screen_group_stock_quote’,
    ‘item_css_id’ => ‘stock’,
    ‘position’ => 50,
    ‘user_has_access’ => $this->current_group->user_has_access
    );
    ///////////////////////

    3) bp-groups-screen.php
    define the action that clicking will elicit:

    function groups_screen_group_stock_quote() {
    global $bp;

    if ( $bp->is_single_item ) {
    // Refresh the group member count meta
    groups_update_groupmeta( $bp->groups->current_group->id, ‘total_member_count’, groups_get_total_member_count( $bp->groups->current_group->id ) );

    do_action( ‘groups_screen_group_stock_quote’, $bp->groups->current_group->id );
    bp_core_load_template( apply_filters( ‘groups_template_group_members’, ‘groups/single/home’ ) );
    }
    }

    The URIs above all go to the groups/single/home because there it loads the header etc and includes the body file depending on the action. So add your pages to that area and then create them in the your_theme/groups/single directory. For the above example I created theme/groups/single/stock-quote.php.

    Cheers


    becskr
    Participant

    @becskr

    I’m having problems with this too – but you shouldn’t be editing the core files as they’ll likely get over written. Please can someone advise me how to do this?

    My now defunct code:
    function new_group_items_setup_nav() {
    global $bp;
    bp_core_new_subnav_item( array(
    ‘name’ => ‘Latest Club Posts’,
    ‘slug’ => ‘recent-posts’,
    ‘parent_url’ => $bp->root_domain.’/’.$bp->groups->slug.’/’.$bp->groups->current_group->slug.’/’,
    ‘parent_slug’ => $bp->groups->slug,
    ‘screen_function’ => ‘show_blogs_from_club’,
    ‘position’ => 20 ) );

    bp_core_new_subnav_item( array(
    ‘name’ => ‘Events’,
    ‘slug’ => ‘events’,
    ‘parent_url’ => $bp->root_domain.’/’.$bp->groups->slug.’/’.$bp->groups->current_group->slug.’/’,
    ‘parent_slug’ => $bp->groups->slug,
    ‘screen_function’ => ‘show_events_from_club’,
    ‘position’ => 20 ) );

    }

    add_action( ‘wp’, ‘new_group_items_setup_nav’, 2 );
    function show_blogs_from_club() {

    //add title and content here – last is to call the members plugin.php template
    add_action( ‘bp_template_title’, ‘show_blogs_from_club_screen_title’ );
    add_action( ‘bp_template_content’, ‘show_blogs_from_club_screen_content’ );
    bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘groups/single/plugins’ ) );
    }

    function show_blogs_from_club_screen_title() {
    echo ‘My Page Title’;
    }
    function show_blogs_from_club_screen_content() {

    // page content goes here
    locate_template( array( ‘groups/single/blog-posts.php’ ), true );
    }

    function show_events_from_club() {

    //add title and content here – last is to call the members plugin.php template
    add_action( ‘bp_template_title’, ‘show_events_from_club_screen_title’ );
    add_action( ‘bp_template_content’, ‘show_events_from_club_screen_content’ );
    bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘groups/single/plugins’ ) );
    }

    function show_events_from_club_screen_title() {
    echo ‘My Page Title’;
    }
    function show_events_from_club_screen_content() {

    // page content goes here
    locate_template( array( ‘groups/single/events.php’ ), true );
    }
    add_action( ‘wp’, ‘new_group_items_setup_nav’, 2 );


    becskr
    Participant

    @becskr

    Please help moderators! I am desperate for an answer…


    Boone Gorges
    Keymaster

    @boonebgorges

    I think the problem is that you’re using `$bp->groups->slug` as the parent_slug. You should be using bp_get_current_group_slug().

    This change affects you because you’re adding items directly to the group nav, rather than using BP_Group_Extension. Read more about the change: http://bpdevel.wordpress.com/2011/09/05/manually-modifying-single-group-navigation-in-bp-1-5/


    becskr
    Participant

    @becskr

    Thank you so much for helping me! It’s worked :)


    abutterworth
    Member

    @abutterworth

    @becskr – where should they go then? In a funtions.php file in my child theme? The answer will help me and anyone else trying to accomplish the above.
    Thanks for the tip.


    becskr
    Participant

    @becskr

    Yes that’s all in functions.php – don’t edit core files because when bp updates they will get overwritten.

    New code snippet:
    bp_core_new_subnav_item( array(
    ‘name’ => ‘Latest Club Posts’,
    ‘slug’ => ‘recent-posts’,
    ‘parent_url’ => $bp->root_domain.’/’.$bp->groups->slug.’/’.$bp->groups->current_group->slug.’/’,
    ‘parent_slug’ => bp_get_current_group_slug(),
    ‘screen_function’ => ‘show_blogs_from_club’,
    ‘position’ => 20 ) );

    Hope that helps :)


    becskr
    Participant

    @becskr

    By the way, the only thing that I changed was the parent slug

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Old custom sub_nav items no longer work in groups….chasing it all down’ is closed to new replies.
Skip to toolbar