BuddyDev

Search

Generate Subnav Tabs

Tagged: 

  • Participant
    Level: Initiated
    Posts: 16
    eGuard on #1393

    Hello Brajesh,

    I have a problem i don’t seem to be able to solve.

    What i am looking to achieve, is to create a subnav tab, for each taxonomy term a specific user is using. The parent nav tab is ‘collections’

    So i have students, these students can submit posts, and these post can have a taxonomy term. The taxonomy is ‘collections’, so each student can have multiple (non-unique) taxonomy terms for which i am looking to create a subnav tab. Creating them manually is not an option as the terms are user generated.

    What i am doing is to pull all taxonomy terms a specific user has used for the taxonomy collection. And then i want to loop the function to create the subnav tab for each term. But somehow i don’t get it to work.

    My code is below and placed in bp-custom.php…

    `
    $userid = bp_displayed_user_id();
    $posts = get_posts( array(‘post_type’ => ‘post’, ‘posts_per_page’ => -1, ‘author’ => $userid) );
    /*$author_terms = array();
    foreach ($posts as $p) {
    $terms = get_the_terms( $p->ID, ‘collection’);
    foreach ($terms as $t) {
    /* echo ‘

  • ‘. $t->name;
    $author_terms[] = $t->name;
    }
    }*
    /*print_r($author_terms);
    $all_categories = list_author_used_terms($userid);

    //print_r($posts);
    /*if($all_categories)
    {
    foreach($all_categories as $row_categ)
    {

    bp_core_new_subnav_item(
    array(
    ‘name’ => __( ucfirst($row_categ), ‘buddypress’ ),
    ‘slug’ => $row_categ,
    ‘position’ => 100,
    ‘screen_function’ => $row_categ.’_display’,
    ‘default_subnav_slug’ => ‘my-collection’,
    ‘parent_url’ => $bp->loggedin_user->domain . $bp->slug . ‘/collections/’,
    ‘parent_slug’ => ‘collections’,
    ) );
    }
    }
    else
    {
    //echo ‘No Category’;
    }*/

    function $row_categ.’_display'() {

    echo $row_categ;
    }
    1

  • Participant
    Level: Initiated
    Posts: 16
    eGuard on #1394

    I tried to edit the post to fix the typo at the end which should be ` instead of 1.
    When i click edit, i get notification “You cannot create new topics.”

  • You must be logged in to reply to this topic.

    This topic is: not resolved