Add a same subcategory to difetent main categories

edited March 28 in Vanilla 3.x Help

Can I do Like this?


Main Category 1

 - Sub Category 1A

 - Sub Category 1B


Main Category 2

 - Sub Category 1A

 - Sub Category 1B


In vanilla 3.3

Comments

  • KasparKaspar ✭✭

    Sorry (god morning to me) just read your question and understood it this time.


    Eh no, don't think so

    Vanillaplus
  • So you are asking the same child category has multi parents? so same sub forum lives in 2 different places?

    Vanillaplus
  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    Generally not. You might be able to tweak some views, but at least the discussioncount in the categories will not be correct. But even that could possibly tweaked.

    You would need a plugin. In /applications/vanilla/views/categories/all.php there are those lines:

    $categories = $this->data('CategoryTree');
    writeCategoryList($categories, 1);
    

    The function writeCategoryList is defined like that:

    if (!function_exists('writeCategoryList')):
       /**
        * Renders a category list (modern view).
        *
        * @param $categories
        * @param int $depth
        */
       function writeCategoryList($categories, $depth = 1) {
           if (empty($categories)) {
               echo '<div class="Empty">'.t('No categories were found.').'</div>';
               return;
           }
    
           ?>
           <div class="DataListWrap">
               <h2 class="sr-only"><?php echo t('Category List'); ?></h2>
               <ul class="DataList CategoryList">
                   <?php
                   foreach ($categories as $category) {
                       writeListItem($category, $depth);
                   }
                   ?>
               </ul>
           </div>
           <?php
       }
    endif;
    


    You would need to copy that function under your plugin class and slightly change it. Find out the structure of $categories and change it the way you want. That should be all that is needed. But since it is dirty tweaking, there might be some unforseeable side effects ¯\_(ツ)_/¯


    Vanillaplus
  • @R_J Thank you for your response & your ideas.. Actually my problem is I made the forum for university students in my country. The learn lot of courses and the coursers have lot of modules. some courses have same modules.

    example:

    Software engineering

    • Application Programming.
    • Architecture and Operating Systems.
    • Core Computing Concepts.
    • Database Systems Development.
    • Networks.


    Electrical and Electronic Engineering

    • Analogue Electronics
    • Analysis of Circuits
    • Digital Electronics
    • Energy Conversion
    • Engineering Design and Practice
    • Introduction to Signals and Communications
    • Mathematics
    • Semiconductor Devices
    • Application Programming

    Engineering and Technology

    • Electrical Engineering
    • Engineering Materials and Design
    • Engineering Mathematics
    • Engineering Principles
    • Introduction to the use of Computers (different name but same contents)


    can you understand my problem?

    Is there are any solutions, ideas?

    can you suggest this kind of educational forum for get ideas about category format?

    I made this forum for university students to learn from home.. so I need your help and a fast solution. thank you!

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    What about

    • Common Modules (or Crossfunctional Modules or whatever)
    • Software Engineering
    • Electrical and Electronic Engineering
    • Engineering and Technology



    Vanillaplus
    • Management & Finance
    • Engineering, manufacturing
    • construction

    other courses also have common modules 😑

Sign In or Register to comment.