Advertisement:

Author Topic: [SOLVED] Show # of ads in subcategories DropDown Menu  (Read 4219 times)

volunteer

  • Full Member
  • ***
  • Posts: 241
[SOLVED] Show # of ads in subcategories DropDown Menu
« on: March 12, 2014, 08:20:00 am »
anyone know how to show the number of ads in each sub-category? or category at least? in the drop down menu

for example: Cars (2)

repurpose theme
« Last Edit: March 13, 2014, 02:54:24 pm by volunteer »

design

  • Hero Member
  • *****
  • Posts: 2619
  • Osclass 3.5 MAC/PC w/ Modern Browsers
Re: Show count of ads in subcategories?
« Reply #1 on: March 12, 2014, 09:18:46 am »
 you would add this line of code (<?php echo osc_category_total_items() ; ?>) next to the name of your category, which looks something like this <?php echo osc_category_name();  ?> or

which will all be enclosed in the <?php while ( osc_has_categories() ) { ?> loop

volunteer

  • Full Member
  • ***
  • Posts: 241
Re: Show count of ads in subcategories?
« Reply #2 on: March 12, 2014, 02:53:59 pm »
thanks!
where exactly to make the number have the same text formatting than the subcategories in the drop drown menu??

Code: [Select]
<div class="topbar-wrapper">
                <?php osc_goto_first_category() ; ?>
                <?php if(osc_count_categories () > 0) { ?>
                <ul class="nav">
                    <?php while ( osc_has_categories() ) { ?>
                    <li class="<?php echo osc_category_slug() ; ?><?php if ( osc_count_subcategories() > ) { ?> menu<?php ?>">
                        <a href="<?php echo osc_search_category_url() ; ?>" <?php if ( osc_count_subcategories() > ) { ?>class="menu"<?php ?>><?php View::newInstance()->_erase('subcategories'); echo osc_category_name() ; ?></a>
                        <?php if ( osc_count_subcategories() > ) { ?>
                        <ul class="menu-dropdown">
                            <?php while ( osc_has_subcategories() ) { ?>

design

  • Hero Member
  • *****
  • Posts: 2619
  • Osclass 3.5 MAC/PC w/ Modern Browsers
Re: Show count of ads in subcategories?
« Reply #3 on: March 12, 2014, 05:40:10 pm »
well as it was not in the that spot in the first place, it will not have been styled-- you will need to do that your self.
do you know how?  :o

volunteer

  • Full Member
  • ***
  • Posts: 241
Re: Show count of ads in subcategories?
« Reply #4 on: March 12, 2014, 07:53:58 pm »
haha no idea.. custom.css?  :P

design

  • Hero Member
  • *****
  • Posts: 2619
  • Osclass 3.5 MAC/PC w/ Modern Browsers
Re: Show count of ads in subcategories?
« Reply #5 on: March 12, 2014, 08:05:19 pm »
let me introduce you to our friendly web browser developer tools.  8)

what browser are you using? or rather how are you viewing your site?

sometimes you will need to activate it in IE and safari. until you see on your tool bar "develop" and from there you will be able to pick an element  to style while actually seeing it in a browser.
I will let all that soak in, do some playing around with it until you get use to it, and before you know it you will have probably completely redesigned your site :-) 

the developer tools will tell you which file to change.

tomshaft

  • Hero Member
  • *****
  • Posts: 862
  • Osshaft for Osclass - Add 650 posts to my total
Re: Show count of ads in subcategories?
« Reply #6 on: March 12, 2014, 08:37:30 pm »
Unbelievable how we got along before those built in  browser dev tools and electric lighting.... ;)

Tom

volunteer

  • Full Member
  • ***
  • Posts: 241
Re: Show count of ads in subcategories?
« Reply #7 on: March 12, 2014, 08:51:43 pm »
thanks for all the tips guys! I will start playing with dev tools now  8)

volunteer

  • Full Member
  • ***
  • Posts: 241
[HOW TO] Show # of ads in subcategories DropDown Menu
« Reply #8 on: March 12, 2014, 11:37:58 pm »
took a look and there is not way I will understand where to put the code with dev tools  :-[

but found it in PHP anyway.

so here it goes in case someone is looking for the same thing

head.php

look for: <?php echo osc_category_name() ; ?></a></li>

and change it to: <?php echo osc_category_name() ; ?> [<?php echo osc_category_total_items() ; ?>]</a></li>

will re post it as {HOW TO]
thank u guys!

What about showing the total of subcategories in the whole site?
<?php echo osc_total_subcategories() ; ?> ?

design

  • Hero Member
  • *****
  • Posts: 2619
  • Osclass 3.5 MAC/PC w/ Modern Browsers
Re: [HOW TO] Show # of ads in subcategories DropDown Menu
« Reply #9 on: March 13, 2014, 12:24:38 am »
as I'm learning this the hard way.. try not to have to many db request (quarries) it is killing my site speed  :-\

volunteer

  • Full Member
  • ***
  • Posts: 241
Re: [HOW TO] Show # of ads in subcategories DropDown Menu
« Reply #10 on: March 13, 2014, 02:18:19 am »
I need to show numbers of items in each subcategory otherwise users will browse empty ones
any other way to do the same without creating more queries?

tomshaft

  • Hero Member
  • *****
  • Posts: 862
  • Osshaft for Osclass - Add 650 posts to my total
Re: [HOW TO] Show # of ads in subcategories DropDown Menu
« Reply #11 on: March 13, 2014, 09:13:39 am »
This will hide empties:
(I think Trains posted this long ago):
Code: [Select]
<?php while ( osc_has_categories() ) { ?>
                                <div class="category">
                                    <h1><strong><span class="category <?php echo osc_category_slug() ; ?>"></span><a 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() ) {
                                                 if(
osc_category_total_items() > ) { ?>

                                                <li><a class="category <?php echo osc_category_slug() ; ?>" 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

Tom

volunteer

  • Full Member
  • ***
  • Posts: 241
Re: [HOW TO] Show # of ads in subcategories DropDown Menu
« Reply #12 on: March 13, 2014, 01:17:20 pm »
thanks Tom!  :)

tomshaft

  • Hero Member
  • *****
  • Posts: 862
  • Osshaft for Osclass - Add 650 posts to my total
Re: [HOW TO] Show # of ads in subcategories DropDown Menu
« Reply #13 on: March 13, 2014, 01:24:30 pm »
If satisfied, make subject solved.