News Flash:
New Version of ShopClass theme 1.4.0 is Released on 13 JUNE 2018, Please upgrade your installation.

Adding number of listings in subcategory

A place to talk about anything related to ShopClass theme in general. This is not the place to ask support questions.
Post Reply
steve
Senior
Posts: 222
Joined: Thu Oct 01, 2015 5:33 pm
Has thanked: 11 times
Been thanked: 4 times

Adding number of listings in subcategory

Post by steve » Thu Dec 08, 2016 10:39 pm

Hi,
1.) In the new update of shopclass (layout 2), we have a modal window which shows the names of all subcategories. How can we show a badge of the number of listings in each subcategory alongside the name?

2.) Also, the layout of the subcategories seem to be more like links. How can i change it to something like "link buttons list" .. like it used to be in the "Report Listing" modal in TUFFCLASSIFIED theme. Something like this - https://getbootstrap.com/components/#list-group-linked

Thanks.

User avatar
tuffadmin
Site Admin
Posts: 1236
Joined: Tue Jan 29, 2013 7:31 pm
Has thanked: 33 times
Been thanked: 111 times

Re: Adding number of listings in subcategory

Post by tuffadmin » Fri Dec 09, 2016 9:22 am

They are same as bootstrap example, but due to our colour scheme you are not seeing any border. Try a different colour scheme.

For item count you can use something like this.

Code: Select all

<span class="badge pull-right"> <?php echo osc_category_total_items() ; ?></span>
Look for tfc_get_subcatlist() function around line no. 1156 and put above code in between li tag.

Currently list-group-item class is on li tag you can move it a tag and remove li tag in above function
like: <a class="list-group-item" href="<?php echo osc_search_category_url() ; ?>"><?php echo osc_category_name();?> </a>
No support for unnecessary PM, use forum for support queries.
Please give us good review if you bought our theme from Osclass Market

steve
Senior
Posts: 222
Joined: Thu Oct 01, 2015 5:33 pm
Has thanked: 11 times
Been thanked: 4 times

Re: Adding number of listings in subcategory

Post by steve » Fri Dec 09, 2016 12:11 pm

tuffadmin wrote:
Fri Dec 09, 2016 9:22 am
They are same as bootstrap example, but due to our colour scheme you are not seeing any border. Try a different colour scheme.

For item count you can use something like this.

Code: Select all

<span class="badge pull-right"> <?php echo osc_category_total_items() ; ?></span>
Look for tfc_get_subcatlist() function around line no. 1156 and put above code in between li tag.

Currently list-group-item class is on li tag you can move it a tag and remove li tag in above function
like: <a class="list-group-item" href="<?php echo osc_search_category_url() ; ?>"><?php echo osc_category_name();?> </a>
line no 1156 where?? Which file name??

steve
Senior
Posts: 222
Joined: Thu Oct 01, 2015 5:33 pm
Has thanked: 11 times
Been thanked: 4 times

Re: Adding number of listings in subcategory

Post by steve » Fri Dec 09, 2016 12:40 pm

Got it, the function is in core-functions.php
Removing the <li> and just using the <a> makes something go wrong. The links dont work, and can't see the number of listings either

User avatar
tuffadmin
Site Admin
Posts: 1236
Joined: Tue Jan 29, 2013 7:31 pm
Has thanked: 33 times
Been thanked: 111 times

Re: Adding number of listings in subcategory

Post by tuffadmin » Sat Dec 10, 2016 1:09 pm

This should work

Code: Select all

/************************************************************\
*Get Subcategories list with given main category 
\************************************************************/
function tfc_get_subcatlist(){
	$categoryId = Params::getParam('maincatId') ;
	osc_get_categories();
	while ( osc_has_categories() ) {
		if (osc_category_id() == $categoryId ){
			if ( osc_count_subcategories() > 0 ) {
				while ( osc_has_subcategories() ) { ?>
						<li class="list-group-item"><a href="<?php echo osc_search_category_url() ; ?>"><?php echo osc_category_name();?> </a>
						<span class="badge pull-right"> <?php echo osc_category_total_items() ; ?></span>
						</li>
				<?php } 
						 
			} 
		}
	}
}
No support for unnecessary PM, use forum for support queries.
Please give us good review if you bought our theme from Osclass Market

steve
Senior
Posts: 222
Joined: Thu Oct 01, 2015 5:33 pm
Has thanked: 11 times
Been thanked: 4 times

Re: Adding number of listings in subcategory

Post by steve » Tue Dec 13, 2016 1:45 am

Hi,
The number of listings show now.. however, the clickable area is just the text link, not the whole section as in the bootstrap example, or as in the report listing popup.

User avatar
tuffadmin
Site Admin
Posts: 1236
Joined: Tue Jan 29, 2013 7:31 pm
Has thanked: 33 times
Been thanked: 111 times

Re: Adding number of listings in subcategory

Post by tuffadmin » Tue Dec 13, 2016 9:47 am

Change this

Code: Select all

<li class="list-group-item"><a href="<?php echo osc_search_category_url() ; ?>"><?php echo osc_category_name();?> </a>
						<span class="badge pull-right"> <?php echo osc_category_total_items() ; ?></span>
						</li>
To this

Code: Select all

<a class="list-group-item" href="<?php echo osc_search_category_url() ; ?>"><?php echo osc_category_name();?><span class="badge pull-right"> <?php echo osc_category_total_items() ; ?></span></a>
No support for unnecessary PM, use forum for support queries.
Please give us good review if you bought our theme from Osclass Market

User avatar
tuffadmin
Site Admin
Posts: 1236
Joined: Tue Jan 29, 2013 7:31 pm
Has thanked: 33 times
Been thanked: 111 times

Re: Adding number of listings in subcategory

Post by tuffadmin » Tue Dec 13, 2016 9:51 am

Change this

Code: Select all

<li class="list-group-item"><a href="<?php echo osc_search_category_url() ; ?>"><?php echo osc_category_name();?> </a>
						<span class="badge pull-right"> <?php echo osc_category_total_items() ; ?></span>
						</li>
To this

Code: Select all

<a class="list-group-item" href="<?php echo osc_search_category_url() ; ?>"><?php echo osc_category_name();?><span class="badge pull-right"> <?php echo osc_category_total_items() ; ?></span></a>
No support for unnecessary PM, use forum for support queries.
Please give us good review if you bought our theme from Osclass Market

Post Reply