How to bring course structure to learning board?

Hi!
I want my student can see course structure when they watch the lesson.
How can i do that?
Please see the picture i attach.
Thank you!

  • Ash
    • WordPress Hacker

    Hello @phuongbinh

    Welcome to WPMU community!

    I hope you are well today and thanks for asking the question.

    Do you mean you want to show course structure at the bottom or top of each unit page? Or just in 1st page of the unit? Or something else? Please suggest.

    Cheers
    Ash

  • Ash
    • WordPress Hacker

    Hello @phuongbinh

    I hope you are well today.

    If you don't use coursepress theme, you need to create an unit page in your theme. The filename should be single-unit.php and should be placed at your child theme folder. In that unit page, you just need to add a shortcode:

    echo do_shortcode( '[course_structure label="Course Structure" show_title="no" show_divider="yes" course_id="'. $course_id .'"]' );

    This is a php code, so should be placed inside of php tag (<?php).

    Please let me know if you need any help with custom template. You will need to send me the theme for that.

    Cheers
    Ash

  • Ash
    • WordPress Hacker

    Hi there

    Would you please try the following code instead of the above shortcode in single-unit.php?

    <div class="custom_unit_details">
    <?php
    
        $unit_class = new Unit( get_the_ID() );
        $unit_pagination = cp_unit_uses_new_pagination( get_the_ID() );
    
        if ( $unit_pagination ) {
            $unit_pages = coursepress_unit_pages( get_the_ID(), $unit_pagination );
        } else {
            $unit_pages = coursepress_unit_pages( get_the_ID() );
        }
    ?>
    <ul>
    <?php
    for ( $i = 1; $i <= $unit_pages; $i++ ) {
    
                    ?>
                    <li class="course_structure_page_li <?php echo $existing_student ? 'single_column' : ''; ?>">
                            <?php
                            $pages_num	 = 1;
                            $page_title	 = $unit_class->get_unit_page_name( $i );
                            ?>
    
                            <label for="page_<?php echo get_the_ID() . '_' . $i; ?>">
                                    <?php
                                    $title		 = '';
                                    if ( $existing_student && $enable_links ) {
                                            $p_title = isset( $page_title ) && $page_title !== '' ? $page_title : __( 'Untitled Page', 'cp' );
                                            $title	 = '<a href="' . trailingslashit( $unit_permalink ) . trailingslashit( 'page' ) . trailingslashit( $i ) . '">' . $p_title . '</a>';
                                    } else {
                                            $title = isset( $page_title ) && $page_title !== '' ? $page_title : __( 'Untitled Page', 'cp' );
                                    }
                                    ?>
    
                                    <div class="tree-page-left">
                                            <?php echo $title; ?>
                                    </div>
                                    <div class="tree-page-right">
    
                                            <?php
                                            if ( isset( $preview_page[ get_the_ID() . '_' . $i ] ) && $preview_page[ get_the_ID() . '_' . $i ] == 'on' && $unit_permalink && !$existing_student ) {
                                                    ?>
                                                    <a href="<?php echo $unit_permalink; ?>page/<?php echo $i; ?>?try" class="preview_option"><?php echo $free_text; ?></a>
                                            <?php } ?>
    
                                    </div>
                            </label>
    
                            <?php ?>
                    </li>
                    <?php
    
    }//page visible
    ?>
    </ul>
    </div>

    You may need to tweak some css styling.

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.