Avideo: Enhancement: navigation menu

Created on 3 Apr 2020  路  5Comments  路  Source: WWBN/AVideo

I offer an improved category navigation menu:

Changes to the navbar.php file
Here is the navbar.php file with the changes: https://vicovi.ru/navbar.zip

What was done:

  1. line 152 added CSS
    li.navsub-toggle .badge {
        float: right;
    }
    li.navsub-toggle a + ul {
        padding-left: 15px;
    }
  1. finalized the function and script for displaying the main categories:
    find (line 934):
                    <?php
                    if (!function_exists('mkSub')) {

                        function mkSub($catId) {
                            global $global;
                            unset($_GET['parentsOnly']);
                            $subcats = Category::getChildCategories($catId);
                            if (!empty($subcats)) {
                                echo "<ul style='margin-bottom: 0px; list-style-type: none;'>";
                                foreach ($subcats as $subcat) {
                                    if (empty($subcat['total'])) {
                                        continue;
                                    }
                                    echo '<li class="' . ($subcat['clean_name'] == @$_GET['catName'] ? "active" : "") . '">'
                                    . '<a href="' . $global['webSiteRootURL'] . 'cat/' . $subcat['clean_name'] . '" >'
                                    . '<span class="' . (empty($subcat['iconClass']) ? "fa fa-folder" : $subcat['iconClass']) . '"></span>  ' . $subcat['name'] . ' <span class="badge">' . $subcat['total'] . '</span></a></li>';
                                    mkSub($subcat['id']);
                                }
                                echo "</ul>";
                            }
                        }

                    }
                    if (empty($advancedCustom->doNotDisplayCategoryLeftMenu)) {
                        $post = $_POST;
                        $get = $_GET;
                        unset($_GET); 
                        unset($_POST);
                        $_GET['current'] = $_POST['current'] = 1;
                        $categories = Category::getAllCategories();
                        foreach ($categories as $value) {
                            if ($advancedCustom->ShowAllVideosOnCategory) {
                                $total = $value['fullTotal'];
                            } else {
                                $total = $value['total'];
                            }
                            if (empty($total)) {
                                continue;
                            }
                            echo '<li class="' . ($value['clean_name'] == @$_GET['catName'] ? "active" : "") . '">'
                            . '<a href="' . $global['webSiteRootURL'] . 'cat/' . $value['clean_name'] . '" >';
                            echo '<span class="' . (empty($value['iconClass']) ? "fa fa-folder" : $value['iconClass']) . '"></span>  ' . $value['name'];
                            if (empty($advancedCustom->hideCategoryVideosCount)) {
                                echo ' <span class="badge">' . $total . '</span>';
                            }
                            mkSub($value['id']);
                            echo '</a></li>';
                        }
                        $_POST = $post;
                        $_GET = $get;
                    }
                    ?>

Replaced by:

                    <?php
                    $parsed_cats = array();
                    if (!function_exists('mkSub')) {

                        function mkSub($catId) {
                            global $global, $parsed_cats;
                            unset($_GET['parentsOnly']);
                            $subcats = Category::getChildCategories($catId);
                            if (!empty($subcats)) {
                                echo "<ul class=\"nav\" style='margin-bottom: 0px; list-style-type: none;'>";
                                foreach ($subcats as $subcat) {
                                    if ($subcat['parentId'] != $catId) {
                                        continue;
                                    }
                                    if (empty($subcat['total'])) {
                                        continue;
                                    }
                                    if (in_array($subcat['id'], $parsed_cats)) {
                                        continue;
                                    }
                                    //$parsed_cats[] = $subcat['id'];
                                    echo '<li class="navsub-toggle ' . ($subcat['clean_name'] == @$_GET['catName'] ? "active" : "") . '">'
                                      . '<a href="' . $global['webSiteRootURL'] . 'cat/' . $subcat['clean_name'] . '" >'
                                      . '<span class="' . (empty($subcat['iconClass']) ? "fa fa-folder" : $subcat['iconClass']) . '"></span>  ' . $subcat['name'] . ' <span class="badge">' . $subcat['total'] . '</span>';
                                    echo '</a>';
                                    mkSub($subcat['id']);
                                    echo '</li>';
                                }
                                echo "</ul>";
                            }
                        }

                    }
                    if (empty($advancedCustom->doNotDisplayCategoryLeftMenu)) {
                        $post = $_POST;
                        $get = $_GET;
                        unset($_GET); 
                        unset($_POST);
                        $_GET['current'] = $_POST['current'] = 1;
                        $categories = Category::getAllCategories();
                        foreach ($categories as $value) {
                            if ($value['parentId']) {
                                continue;
                            }
                            if ($advancedCustom->ShowAllVideosOnCategory) {
                                $total = $value['fullTotal'];
                            } else {
                                $total = $value['total'];
                            }
                            if (empty($total)) {
                                continue;
                            }
                            if (in_array($value['id'], $parsed_cats)) {
                                continue;
                            }
                            //$parsed_cats[] = $value['id'];
                            echo '<li class="navsub-toggle ' . ($value['clean_name'] == @$_GET['catName'] ? "active" : "") . '">'
                              . '<a href="' . $global['webSiteRootURL'] . 'cat/' . $value['clean_name'] . '" >';
                                echo '<span class="' . (empty($value['iconClass']) ? "fa fa-folder" : $value['iconClass']) . '"></span>  ' . $value['name'];
                                if (empty($advancedCustom->hideCategoryVideosCount)) {
                                    echo ' <span class="badge">' . $total . '</span>';
                                }
                              echo '</a>';
                              mkSub($value['id']);
                            echo '</li>';
                        }
                        $_POST = $post;
                        $_GET = $get;
                    }
                    ?>
  1. added js script on line 1052
    <script>
      $(document).ready(function() {
        setTimeout(function() {
          $('.nav li.navsub-toggle a:not(.selected) + ul').hide();
          var navsub_toggle_selected = $('.nav li.navsub-toggle a.selected');
              navsub_toggle_selected.next().show();
              navsub_toggle_selected = navsub_toggle_selected.parent();

          var navsub_toggle_selected_stop = 24;
          while(navsub_toggle_selected.length) {
            if($.inArray(navsub_toggle_selected.prop('localName'), ['li', 'ul']) == -1) break;
            if(navsub_toggle_selected.prop('localName') == 'ul') {
              navsub_toggle_selected.show().prev().addClass('selected');
            }
            navsub_toggle_selected = navsub_toggle_selected.parent();

            navsub_toggle_selected_stop--;
            if(navsub_toggle_selected_stop < 0) break;
          }
        }, 500);


        $('.nav').on('click', 'li.navsub-toggle a:not(.selected)', function(e) {
          var a = $(this),
              b = a.next();
          if(b.length) {
            e.preventDefault();

            a.addClass('selected');
            b.slideDown();

            var c = a.closest('.nav').find('li.navsub-toggle a.selected').not(a).removeClass('selected').next();

            if(c.length) c.slideUp();
          }
        });
      });
    </script>
wontfix

Most helpful comment

Congratulations, I really like that.

can you please send a pull request?
So your name will appear as a contributor.

All 5 comments

Congratulations, I really like that.

can you please send a pull request?
So your name will appear as a contributor.

@DanielnetoDotCom How can I do it?

I found a link to GitHub help Maybe this will help GitHub Help link

I tried to do it

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

syldri picture syldri  路  3Comments

shebanet picture shebanet  路  4Comments

matthall1998 picture matthall1998  路  4Comments

wetubeclub picture wetubeclub  路  3Comments

CorpCaleCloud picture CorpCaleCloud  路  4Comments