Advertisement:

Author Topic: show only the first 9 Categories on home page - possible? Modern Theme  (Read 5169 times)

proclass

  • Jr. Member
  • **
  • Posts: 60
I have more then 50  categories (per 3-4 Subcategory). On first(home) page need only 9-12  Categories.


For subcat (but don't work for main categories) :
http://forums.osclass.org/development/show-only-the-first-5-subcategories-per-category-possible/

Thank you for help

RajaSekar

  • Hero Member
  • *****
  • Posts: 791
  • ராஜசேகர்

try this one

Locate these line in main.php

Code: [Select]
while ( osc_has_categories() ){

Replace the above line with this
Code: [Select]
while ( osc_has_categories() ){
if(osc_category_name()=="Vehicles"||osc_category_name()=="Real estate")

the above code shows only 2 categories fields(Vehicles,Real estate) and change code to show extra categories whatever you want

proclass

  • Jr. Member
  • **
  • Posts: 60
unfortunately don't work

Jesse

  • Hero Member
  • *****
  • Posts: 631
  • Out of my mind, back in 5 minutes
If you only want to show a certain  number of categories, just set a variable up to count the number of categories being displayed. Then once you've reached your desired number of categories to display, stop.

Such as...

Code: [Select]
index = 0;
while ( osc_has_categories() && index < 12)
{
    ...
    ...
    index++;
}

Change '12' to however many categories you wish to show.
« Last Edit: May 10, 2012, 05:07:41 am by Jesse »

jeller

  • Newbie
  • *
  • Posts: 15
Re: show only the first 9 Categories on home page - possible? Modern Theme
« Reply #4 on: February 19, 2013, 08:56:26 pm »


Sorry my Code is orginal modern Theme. i want display has_category   9  and has_subcategorys  2. Please can post the code fpr me?

Thank you.

Code: [Select]

                    <?php while ( osc_has_categories() ) { ?>
                        <div class="category">
                            <h1><strong><a class="category cat_<?php echo osc_category_id() ; ?>" href="<?php echo osc_search_category_url() ; ?>"><?php echo osc_category_name() ; ?></a> <span>(<?php echo osc_category_total_items() ; ?>)</span></strong></h1>
                            <?php if ( osc_count_subcategories() > ) { ?>
                                <ul>
                                   
                                   
                                    <?php while ( osc_has_subcategories() ) { ?>
                                        <li><a class="category cat_<?php echo osc_category_id() ; ?>" href="<?php echo osc_search_category_url() ; ?>"><?php echo osc_category_name() ; ?></a> <span>(<?php echo osc_category_total_items() ; ?>)</span></li>
                                    <?php ?>
                                </ul>
                            <?php ?>
                        </div>
                        <?php
                            
if (($col==&& $i==$col1_max_cat) || ($col==&& $i==$col2_max_cat) || ($col==&& $i==$col3_max_cat)) {
                                
$i 1;
                                
$col++;
                                echo 
'</div>';
                                if(
$x $total_categories) {
                                    echo 
'<div class="col c'.$col.'">';
                                }
                            } else {
                                
$i++ ;
                            }
                            
$x++ ;
                        
?>

                    <?php ?>


trains58554

  • Osclass contributor
  • Hero Member
  • *****
  • Posts: 3642
  • osCanyon, the class of Osclass
Re: show only the first 9 Categories on home page - possible? Modern Theme
« Reply #5 on: February 20, 2013, 07:39:47 pm »
Hi jeller,

All you have to do is change line 57 $total_categories   = osc_count_categories() ; to this $total_categories   = 9 ; and then you will only have 9 categories loaded on the home page.

Jay