Osclass forums

Development => Development => Topic started by: proclass on May 09, 2012, 01:43:47 pm

Title: show only the first 9 Categories on home page - possible? Modern Theme
Post by: proclass on May 09, 2012, 01:43:47 pm
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
Title: Re: show only the first 9 Categories on home page - possible? Modern Theme
Post by: RajaSekar on May 09, 2012, 02:55:26 pm

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
Title: Re: show only the first 9 Categories on home page - possible? Modern Theme
Post by: proclass on May 09, 2012, 08:38:33 pm
unfortunately don't work
Title: Re: show only the first 9 Categories on home page - possible? Modern Theme
Post by: Jesse on May 10, 2012, 05:03:47 am
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.
Title: Re: show only the first 9 Categories on home page - possible? Modern Theme
Post by: jeller 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 ?>

Title: Re: show only the first 9 Categories on home page - possible? Modern Theme
Post by: trains58554 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