Skip to:
Content
Pages
Categories
Search
Top
Bottom

problem displaying single item

  • Avatar of Grosbouff
    grosbouff
    Participant

    @grosbouff

    Hi; i’m working on a classifieds component.

    I changed some stuff in the classifieds permalink and now singles items doesn’t display in the right template.

    I think it is a bp_core_reset_subnav_items/bp_core_add_nav_default/bp_core_add_subnav_item problem :

    e.g. : my classified has ../wordpress-mu/classifieds/employers/prod-av/test81 for permalink.

    I “load” the classified like :

    function bp_classifieds_setup_nav() {
    global $bp, $classified_obj, $current_blog;
    $last_action_variable = $bp->action_variables[count($bp->action_variables)-1];
    if ( $classified_id = BP_Classifieds_Classified::classified_exists($last_action_variable) ) {
    /* This is a single classified page. */
    $bp->is_single_item = true;
    $classified_obj = new BP_Classifieds_Classified( $classified_id );

    it works, as the statement if ( $classified_id = BP_Classifieds_Classified::classified_exists($last_action_variable) ) is fired.

    Later, in the same function bp_classifieds_setup_nav(); I set up the menu :

    }else if ( $bp->is_single_item ) {

    $bp->current_item = $last_action_variable;

    //TO FIX ?
    $bp->current_action = $bp->action_variables[0];
    array_shift($bp->action_variables);
    $bp->bp_options_title = $classified_obj->name;

    $classified_link = bp_get_classified_permalink($classified_obj) . '/';
    $category=new BP_Classifieds_Categories($classified_obj->category);
    $classified_parent_slug = $category->slug;
    // Check classified access
    if (( 'published' == $classified_obj->status ) || (classifieds_is_moderator())) {
    $has_access=true;
    }else {
    $has_access=false;
    }
    // Reset the existing subnav items
    bp_core_reset_subnav_items($classified_parent_slug);
    bp_core_add_nav_default( $classified_parent_slug, 'classifieds_screen_single', __('home','classifieds-slugs') );
    bp_core_add_subnav_item( $classified_parent_slug, __('home','classifieds-slugs'), __('Home', 'buddypress'), $classified_link , 'classifieds_screen_single', 'classified-home');

    So the classifieds_screen_single function should fire; but it is not.

    Any idea of why ?

    Thanks !

Viewing 10 replies - 1 through 10 (of 10 total)
  • Avatar of Jeff Sayre
    Jeff Sayre
    Participant

    @jeffsayre

    Which version of BuddyPress are you running? As of trunk r1599 (which is just over 2 months ago), the functions bp_core_add_nav_default() and bp_core_add_subnav_item were deprecated, replaced by bp_core_new_nav_item() and bp_core_new_subnav_item().

    Avatar of Grosbouff
    grosbouff
    Participant

    @grosbouff

    1.0.3…

    I would like to upgrade to 1.1 but it doesn’t work for me.

    Anyway; what’s wrong with this code ?

    Can’t find the solution.

    Hi guess it’s a problem with $classified_parent_slug/$classified_link…

    Avatar of Grosbouff
    grosbouff
    Participant

    @grosbouff

    Hi Jeff, I updated BP to use bp_core_new_subnav_item().

    I’m working inside a class; and I would like to call the “screen” function of that class with my submenu.

    I try

    /* Add the subnav items to the groups nav item */
    bp_core_new_subnav_item( array( 'name' => __( 'Group Map', 'bp-mappress' ), 'slug' => 'group-map', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => array(&$this, 'screen'), 'position' => 50, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'group-map' ) );
    }

    But it’s not working…

    is

    <br />
    'screen_function' => array(&$this, 'screen')<br />

    correct ?

    Thanks !

    Doing that isn’t supported. File it as an enhancement ticket for v1.2.

    Avatar of Grosbouff
    grosbouff
    Participant

    @grosbouff

    seems it is :

    inside function bp_core_new_subnav_item( $args = ” ) :

    if ( ( $bp->current_action == $slug && $bp->current_component == $parent_slug ) && $user_has_access ) {
    if ( !is_object($screen_function[0]) )
    add_action( 'wp', $screen_function, 3 );
    else
    add_action( 'wp', array( &$screen_function[0], $screen_function[1] ), 3 );
    }

    ??

    It is supported, and it should work.

    Avatar of kapil
    kapil
    Participant

    @techkapil

    My bp component working fine in 1.0.2 but giving me warning in 1.1.1

    I replaced

    bp_core_add_nav_item(

    __( ‘Example’, ‘example ),

    $bp->example->slug

    );

    by

    $args = array(

    ‘name’ => __( ‘Example’, ‘example’ ),

    ‘slug’ => $bp->example->slug,

    ‘item_css_id’ => false,

    ‘show_for_displayed_user’ => true,

    ‘site_admin_only’ => false,

    ‘position’ => 99,

    ‘screen_function’ => false,

    ‘default_subnav_slug’ => false

    );

    bp_core_new_nav_item($args);

    but giving me warning

    call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, ” was given in /opt/lampp/htdocs/wordpress-mu4/wp-includes/plugin.php on line 414

    Thanks in advance :-)

    Avatar of Jeff Sayre
    Jeff Sayre
    Participant

    @jeffsayre

    @kapil-

    You need to list a valid screen function in the ‘screen_function’ element. Setting it to false is probably what is triggering the error.

    Avatar of kapil
    kapil
    Participant

    @techkapil

    Hey Jeff Thanks!It worked!

    It seems screen_function is mandatory here…! Where Codex says its optional.(http://codex.buddypress.org/developer-docs/functions/core/bp_core_new_nav_item/)

    Avatar of Jeff Sayre
    Jeff Sayre
    Participant

    @jeffsayre

    @kapil

    I’m glad that solved your issue!

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

You must be logged in to reply to this topic.