N
N
NeveR3d2018-11-27 23:24:57
DLE
NeveR3d, 2018-11-27 23:24:57

Displaying categories in the news as in the admin panel?

Is there any way to display the category to which it belongs in the news? But how in the admin panel, i.e. in the tree?
I took the code from function.php, but unfortunately all categories are displayed

<?PHP
if( !count( $cat_info ) ) {

} else {

  function DisplayCategories($parentid = 0, $sublevelmarker = false) {
    global $lang, $cat_info, $config, $dle_login_hash;

    $cat_item = "";
    
    if( count( $cat_info ) ) {
      
      foreach ( $cat_info as $cats ) {
        if( $cats['parentid'] == $parentid ) $root_category[] = $cats['id'];
      }
      
      if( count( $root_category ) ) {
        
        foreach ( $root_category as $id ) {
          
          $category_name = $cat[$id];
          
          if( $config['allow_alt_url'] ) $link = "<a href=\"" . $config['http_home_url'] . get_url( $id ) . "/\" target=\"_blank\">" . stripslashes( $cat_info[$id]['name'] ) . "</a>";
          else $link = "<a href=\"{$config['http_home_url']}index.php?do=cat&category=" . $cat_info[$id]['alt_name'] . "\" target=\"_blank\">" . stripslashes( $cat_info[$id]['name'] ) . "</a>";

          $cat_item .= "<li class=\"dd-item\" data-id=\"{$cat_info[$id]['id']}\"><div class=\"dd-handle\"></div><div class=\"dd-content\"> {$link} </div>";
          
          $cat_item .= DisplayCategories( $id, true );
        }

        if( $sublevelmarker ) return "<ol class=\"dd-list\">".$cat_item."</ol>"; else return $cat_item;

      }
    }
    
  }



  echo DisplayCategories();
}
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Vladimirovich, 2018-12-15
@spamboo

https://dle-faq.ru/modules/18553-avtomaticheskiy-v...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question