Skip to:
Content
Pages
Categories
Search
Top
Bottom

Adding plugin subnav edit screen


  • mikelast
    Participant

    @mikelast

    I am trying to understand the process behind adding an edit screen to buddypress. I am using latest buddypress 3.0.0, bp_nouvea theme. I have created custom plugin and added new marketplace features to the logged in users profile area. I have screens set up to create products and to list the products but I cant figure out how to edit those products. I was hoping to be able to pass in a postID to the slug, and then when we load up the page with the $_GET variable set, we pull all data for the specified ID. Is there a better way to do this? here is what I have at the moment:

    /**
    	 * Add a new sub nav section for the marketplace. Create + add the marketplace edit link for the marketplace in the users profile.
    	 */
    	public function addMarketplaceEditNavItems() {
    		global $bp;
    		$marketPlaceEditItem = [
    			'name'            => 'Create product listing',
    			// Display name for the nav item.
    			'slug'            => 'edit',
    			// URL slug for the nav item.
    			'parent_slug'     => 'myq_' . $this->name,
    			// URL slug of the parent nav item.
    			'parent_url'      => bp_loggedin_user_domain() . 'myq_' . $this->name . '/',
    			// URL of the parent item.
    			'item_css_id'     => 'myq-' . $this->name . '__edit',
    			// The CSS ID to apply to the HTML of the nav item.
    			'user_has_access' => bp_is_my_profile(),
    			// Can the logged in user see this nav item?
    			'position'        => 100,
    			// Index of where this nav item should be positioned.
    			'screen_function' => [ $this, 'addMarketplaceEditScreen' ],
    		];
    		bp_core_new_subnav_item( $marketPlaceEditItem );
    	}
Viewing 2 replies - 1 through 2 (of 2 total)

  • shanebp
    Moderator

    @shanebp

    Rather than add a nav item, just put an edit link in each item in your list of products.
    Point the links to the same screen as the product list.
    In the code for the product list, do an early check for a GET or POST variable, and if found, get the product id variable, open an edit form and fill in the product fields.


    mikelast
    Participant

    @mikelast

    OK what you’ve said has worked, Im just wondering if that is “best practise”

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar