Loading


Advertisement:

Author Topic: Bender Red - Homepage - Amending Sub-Categories  (Read 404 times)

bigfreeads

  • Newbie
  • *
  • Posts: 12
Bender Red - Homepage - Amending Sub-Categories
« on: October 02, 2016, 01:32:05 pm »
Hello,

I have located many different threads about this however a lot seem incomplete or have disappeared due to time passing by from the recent posts and there has been version changes of Bender Red that means the older posts seem to break everything.

I would like to have just the main categories because if you look at http://bigfreeads.co.uk you can see with my categories the page is very long.

I am ok with copying and pasting code into various places but am not very good at all with PHP hence me choosing a pre-built option such as OsClass.

I have found this in the template folder Functions.php which contains:

<?php
                    $_slug      = osc_category_slug();
                    $_url       = osc_search_category_url();
                    $_name      = osc_category_name();
                    $_total_items = osc_category_total_items();
                    if ( osc_count_subcategories() > 0 ) { ?>
                    <span class="collapse resp-toogle"><i class="fa fa-caret-right fa-lg"></i></span>
                    <?php } ?>
                    <?php if($_total_items > 0) { ?>
                    <a class="category <?php echo $_slug; ?>" href="<?php echo $_url; ?>"><?php echo $_name ; ?></a> <span>(<?php echo $_total_items ; ?>)</span>
                    <?php } else { ?>
                    <a class="category <?php echo $_slug; ?>" href="#"><?php echo $_name ; ?></a> <span>(<?php echo $_total_items ; ?>)</span>
                    <?php } ?>
                 </h1>
                 <?php if ( osc_count_subcategories() > 0 ) { ?>
                   <ul>
                         <?php while ( osc_has_subcategories() ) { ?>
                             <li>
                             <?php if( osc_category_total_items() > 0 ) { ?>
                                 <a class="category sub-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>
                             <?php } else { ?>
                                 <a class="category sub-category <?php echo osc_category_slug() ; ?>" href="#"><?php echo osc_category_name() ; ?></a> <span>(<?php echo osc_category_total_items() ; ?>)</span>
                             <?php } ?>
                             </li>
                         <?php } ?>

But when I remove this it breaks the homepage. I tried this:  http://forums.osclass.org/bender/how-to-limit-number-of-sub-categories-to-5-on-homepage-17185/

Ideally I would like it a bit like the mobile version where they can be clicked on and then expand so the code does exist somewhere on the site as its perfect on my mobile phone.  So hopefully it would be the case of locating that code and pasting it here instead.  But nothing seems as simple as that.

It would also be great if at the same time categories with no listings could be hidden until there is an advert available for that category.

I am playing around with different templates so the site may change but I ideally would like to stick with Bender Red.
« Last Edit: October 02, 2016, 01:58:05 pm by bigfreeads »

teseo

  • Hero Member
  • *****
  • Posts: 5644
Re: Bender Red - Homepage - Amending Sub-Categories
« Reply #1 on: October 02, 2016, 02:46:36 pm »
Hi,

While you're populating your site, the easiest thing you can do is to hide subcategorĂ­es with no ads, just comment or delete this line there:

Code: [Select]
<a class="category sub-category <?php echo osc_category_slug() ; ?>" href="#"><?php echo osc_category_name() ; ?></a> <span>(<?php echo osc_category_total_items() ; ?>)</span>
Regards

bigfreeads

  • Newbie
  • *
  • Posts: 12
Re: Bender Red - Homepage - Amending Sub-Categories
« Reply #2 on: October 02, 2016, 05:49:03 pm »
Hi Teseo,  Thanks again for your help.

I have tried commenting out using // Hide Subcategories but this has resulted in // Hide Subcategories replacing all of the category names.  Its on the site at the moment.

Whats the correct way to comment out php, i though it was just a // at the start of the line.

bigfreeads

  • Newbie
  • *
  • Posts: 12
Re: Bender Red - Homepage - Amending Sub-Categories
« Reply #3 on: October 02, 2016, 05:59:07 pm »
Ahhh, think I did it:

<?php

/*

<a class="category sub-category <?php echo osc_category_slug() ; ?>" href="#"><?php echo osc_category_name() ; ?></a> <span>(<?php echo osc_category_total_items() ; ?>)</span>
 

*/

?>
« Last Edit: October 02, 2016, 06:01:13 pm by bigfreeads »

teseo

  • Hero Member
  • *****
  • Posts: 5644
Re: Bender Red - Homepage - Amending Sub-Categories
« Reply #4 on: October 02, 2016, 06:15:31 pm »
No, comments for HTML code have different format than those for PHP:

Code: [Select]
<!--    <a class="category sub-category <?php /*echo osc_category_slug() ; */?>" href="#"><?php /*echo osc_category_name() ; */?></a> <span>(<?php /*echo osc_category_total_items() ; */?>)</span>
-->

Better use at least Notepad++ for edition ("Toggle Block Comment"), the program will take care of it.

Regards