Author Topic: How to add a pagination for the sub-categories (foreach modifing) - core  (Read 806 times)

khalilghenimi

  • Beginner
  • *
  • Posts: 4
Hello, I am using Joomla 2.5.11 and Virtuemart 2.0.20b.

I want to add pagination for the sub-categories, i have searched from the back-end for an option that can solve the problem but i can't found anything.

I have many sub-categories in many Category (55 exp) so the page has becomes so long and not beautiful.

I decided to modify the core code of Virtuemart, so i have gone to : /components/com_virtuemart/views/category/tmpl/default.php to add a pagination, but i can't do it alone, can anyone help me ?

so there is a foreach on the class : category-view that has the function of showing all categories:

Quote

foreach ($this->category->children as $category) {
            // Show the horizontal seperator
            if ($iCol == 1 && $iCategory > $categories_per_row) {
               ?>
               <div class="horizontal-separator"></div>
               <?php
            }

            // this is an indicator wether a row needs to be opened or not
            if ($iCol == 1) {
               ?>
         <div class="row">
         <?php
            }

            // Show the vertical seperator
            if ($iCategory == $categories_per_row or $iCategory % $categories_per_row == 0) {
               $show_vertical_separator = ' ';
            } else {
               $show_vertical_separator = $verticalseparator;
            }

            // Category Link
            $caturl = JRoute::_ ('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $category->virtuemart_category_id);

            // Show Category
            ?>
            <div class="category floatleft<?php echo $category_cellwidth . $show_vertical_separator ?>"">
               <div class="spacer">
                  <h2>
                     <a class="sous_cat" href="<?php echo $caturl ?>" title="<?php echo $category->category_name ?>">
                        
                        
                     <div >   <?php // if ($category->ids) {
                        echo $category->images[0]->displayMediaThumb ("", FALSE);
                        //} ?><br/></div>
                        <div class="titre_cat"><?php echo $category->category_name ?> </div>
                     </a>
                  </h2>
               </div>
            </div>
            <?php
            $iCategory++;

            // Do we need to close the current row now?
            if ($iCol == $categories_per_row) {
               ?>
               <div class="clear"></div>
      </div>
         <?php
               $iCol = 1;
            } else {
               $iCol++;
            }
            $i = $i+1 ;
         }




Anyone can advise me what to do to let this foreach show for example 6 sub-categories per page? If it is possible to do it without refreshing the page will be so good.

Thank you.