Home Forums Theme Support Dokan Creating a dashboard page

This topic is: not resolved

This topic contains 13 replies, has 2 voices, and was last updated by  towhid 4 years, 2 months ago.

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #41186

    Bryan
    Member
    Post count: 20

    I have hooked into the dokan dashboard menu and have added a menu item.

    function my_function( $urls ) {
    $page_id = ‘1';
    $urls[‘zip'] = array(
    ‘title' => __( ‘My Tab', ‘dokan'),
    ‘icon' => ‘‘,
    ‘url' => get_permalink( $page_id )
    );
    return $urls;
    }
    add_filter( ‘dokan_get_dashboard_nav', ‘my_function' );

    I then created some shortcode to to add into a page. The page loads when I click on the new tab that I created, however it is not styled like the other dashboard pages.
    What do I need to do to make the linked page look like other dashboard pages?

    #41202

    towhid
    Participant
    Post count: 4505

    Hello Bryan,

    Please allow me some time to workout with your code as a test purpose. After then I will give you a reply.

    Thank you ๐Ÿ™‚

    #41347

    Bryan
    Member
    Post count: 20

    The following code is what I have currently come up with. This code will create a new dashboard menu item and connects that link to a page that has been created with shortcode. Additionally this code check to see if the user is logged in and allowed to sell items.

    The only thing that I cannot seem to get working are the styles and scripts associated with the dashboard page. What are the styles and scripts that I would need to load to get this new page looking like the others?

    < ?php /** * Insert new URL's to the dashboard navigation bar * * @param array $urls * * @return array */ function x_dokan_new_nav( $urls ) { $page_id = '1'; $urls['test'] = array( 'title' => __( ‘New Tab', ‘dokan'),
    ‘icon' => ‘‘,
    ‘url' => get_permalink( $page_id )
    );

    return $urls;
    }

    add_filter( ‘dokan_get_dashboard_nav', ‘x_dokan_new_nav' );

    /*
    *
    *Redirect the user if they are not logged in
    *
    */
    function x_dash_redirect(){
    if ( ! is_user_logged_in() && is_page( ‘new-dashboard-page' )) {
    wp_safe_redirect( home_url().'/my-account' );
    exit;
    }
    }

    add_action( ‘template_redirect', ‘x_dash_redirect' );

    /*
    *
    *Shortcode for page
    *
    */
    function x_new_dashboard_content(){

    $user_id = get_current_user_id();

    ?>

    < ?php dokan_get_template( 'dashboard-nav.php', array( 'active_menu' => ‘test' ) ); ?>

    < ?php /* *Check if user is a seller */ if( ! dokan_is_seller_enabled( $user_id )){ dokan_seller_not_enabled_notice(); }else{ ?>

    Test!
    < ?php } ?>

    < ?php } add_shortcode( 'x_new_dashboard_content', 'x_new_dashboard_content' ); ?>

    #41406

    towhid
    Participant
    Post count: 4505

    Hello Bryan,

    Can you please let me know in which file you have paste this code?

    Thank you ๐Ÿ™‚

    #41428

    Bryan
    Member
    Post count: 20

    I have placed this file in a new plugin file. There is another file within that same plugin file which activates the plugin and includes this file. I have not changed any of the core dokan files.
    website\wp-content\plugins\new-plugin\this-file.php

    Everything is working it is just the css and perhaps some js that is not loading. There are a lot of css and js files loaded on the dashboard pages and I am having a hard time figuring out which ones need to be included in the new dashboard page.

    #41606

    Bryan
    Member
    Post count: 20

    Any luck on this?

    #41702

    towhid
    Participant
    Post count: 4505

    Hello Bryan,

    Sorry for my late reply. Please allow me some time. I will be back to you as early as possible problely tomorrow I will try to reply something as my best.

    Thank you ๐Ÿ™‚

    #41706

    Bryan
    Member
    Post count: 20

    No worries.

    #41921

    towhid
    Participant
    Post count: 4505

    Hello Bryan,

    Can you please followup my instruction and see how it sees:

    Step 1: Please create a page named “mytab.php” under plugins/wedevs-dokan-plugin/templates/

    Step 2: Please open plugins wedevs-dokan-plugin/includes/template-tags.php and put this code

    function prefix_dokan_add_seller_nav( $urls ) {
        
        $urls['help'] = array(
            'title' => __( 'My Tab', 'dokan'),
            'icon'  => '<i class="fa fa-users"></i>',
            'url'   => dokan_get_navigation_url( 'mytab' )
        );
    
        return $urls;
    }
    
    add_filter( 'dokan_get_dashboard_nav', 'prefix_dokan_add_seller_nav' ); 
    
    function load_mytab_template( $query_var ) {
        if( isset( $query_var['mytab'] ) ) {
            dokan_get_template_part( 'mytab' );
            return;
        }
    }
    
    add_action( 'dokan_load_custom_template', 'load_mytab_template'); 

    Step 3: Please open yourtheme/functions.php and paste this code

    function load_mytab_rewrite( $query_var ) {
    
        $query_var['mytab'] = 'mytab';
        return $query_var;
    }
    
    add_filter( 'dokan_query_var_filter', 'load_mytab_rewrite',20 ); 

    After then you will see a menu named “My Tab” with same design of other dashboard page.

    Try this instruction and let me know the result.

    Thank you ๐Ÿ™‚

    #42176

    Bryan
    Member
    Post count: 20

    The tab appears, however when I click on it it states “That page cannot be found”. Is there a specific location within these files that I need to add this code to. Also I am using the most recent version of the Dokan theme with the plugin if this helps any.

    #42211

    towhid
    Participant
    Post count: 4505

    Hello,

    Make sure you have set your permalinks as post name and product. Please navigate to Settings->Permalinks and Set your permalinks as Post name and Product. Please check and let me know.

    Thank you ๐Ÿ™‚

    #42259

    Bryan
    Member
    Post count: 20

    This works!!! The only issue now is that the active tab is not highlighted. I have used the following code within the mytab.php file:

    < ?php dokan_get_template( 'dashboard-nav.php', array( 'active_menu' => ‘mytab' ) ); ?>

    If I change ‘mytab' to another menu name such as ‘settings', the ‘settings' tab will display as active, it only seems to not work for the new tab. What could be causing the the “My Tab” to not display as the active tab?

    Thanks for getting this working as well as it is by the way.

    #42385

    Bryan
    Member
    Post count: 20

    I got it working. the code you provided worked fine, I made a syntax error. Thank you for your help on this issue.

    #42394

    towhid
    Participant
    Post count: 4505
    This reply has been marked as private.
Viewing 14 posts - 1 through 14 (of 14 total)

The topic ‘Creating a dashboard page’ is closed to new replies.