Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

php navigation - changing the default active tab

Posted on 2011-04-18
29
Medium Priority
?
577 Views
Last Modified: 2012-05-11
On this page is there a way to change the default tab to "pendant" from "view all'?
http://66.147.244.225/~minimosa/category/sterling-silver-pendant/

Attached is the php code for this page.
categorySubNavi.php
0
Comment
Question by:carolsanjose
  • 14
  • 12
26 Comments
 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 35420835
The active tab should have the following HTML code:
<li class="active"><a href="TabURL">Text</a></li>

Open in new window


As you can see, the CSS class "active" is added to the tag "li" so it appear selected.

In your PHP code, change the line:
$catnam	= trim($parts2[1]);

Open in new window


To:
$catnam	= "Put the category name that you would like to select here";

Open in new window

0
 

Author Comment

by:carolsanjose
ID: 35424405

I tried adding the code above to the php file listed & it didn't work.
No categories where highlighted & I didn't know what name to add since it is the 1st subcategory in the category.  All of the category pages will have different 1st subcategories.

Thanks for trying to help.

 
0
 

Author Comment

by:carolsanjose
ID: 35424422
How do I remove the view all tab and have the 1st sub category tab be active?

Please tell me what to edit in the attached php file.

THank you.

<?php 
// Sub Navigation for product categories for orientation. Brace yourself! (modify at your own risk)
//only run the foreach if categories were found
?>
<div class="SubCatNav">
	
		
	<?php
	$orderby 	= $OPTION['wps_catSubNav_orderbyOption'];
	$order 		= $OPTION['wps_catSubNav_orderOption'];
	
	if (!empty($childrenCats)) {
		$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->term_id.'&hide_empty=0&style=none')),0,-6));
	#}elseif((empty($childrenCats)) && ($this_category->category_parent!=0)) {
		#$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->term_id.'&hide_empty=0&style=none')),0,-6));
	} else {
		$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->parent.'&hide_empty=0&style=none&depth=1')),0,-6));
	}	
	
	
	//only run the foreach if categories were found
	if (trim($cats[0]) != 'No cate') {  
		//how many rows?
		$wanted_rows	= $OPTION['wps_catSubNav_rows'];
		$num			= count($cats);
		$counter		= 1;			
		$container 		= '<ul>';
		
		foreach($cats as $cat){
			//set an active class on the current category				
			$parts1 = explode("</a>",$cat);						
			$parts2 = explode(">",$parts1[0]);
			$catnam	= trim($parts2[1]);	
			$the_li_class = ($this_category->name == $catnam ? 'active' : NULL);
			
			if($counter % $wanted_rows == 0){
				$container .= "<li class='$the_li_class'>".$cat .'</li></ul><ul>';					
			} else {
				$container .= "<li class='$the_li_class'>".$cat.'</li>';
			}
			
			$counter++;
		}
		wp_reset_query();
		
		$ending = substr($container,-4);
		if($ending == '<ul>'){
			$container = substr($container,0,-4);
		}
		
		echo $container;
	} ?>
	<ul class="viewAll">
		<?php if (!empty($childrenCats)) { ?>
			<li class="active"><a href="<?php echo get_category_link($this_category->term_id);?>"><?php _e('view all','wpShop');?></a></li>
		<?php #} elseif((empty($childrenCats)) && ($this_category->category_parent!=0)) { ?>
			<!--<li class="active"><a href="<?php echo get_category_link($this_category->term_id);?>"><?php _e('view all','wpShop');?></a></li>-->
		<?php } else { ?>
			<li><a href="<?php echo get_category_link($this_category->parent);?>"><?php _e('view all','wpShop');?></a></li>
		<?php } ?>
	</ul>
</div><!--end "Sub Navigation" section-->
<p style="float:left;margin-top:-20px;margin-left:20px;">Click image to 
 details:</p>

Open in new window

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 35426315
Please post your new question URL so I can help you further.
0
 

Author Comment

by:carolsanjose
ID: 35426527
ON this page:
http://66.147.244.225/~minimosa/category/tile-gallery/

How do I change the active landing tab from view all to the first tab listed?  It will be a different 1st tab on other pages, so I can't just enter the name of the tab into the php file listed below.

How do I edit the code in the file list below to make the active landing tab the first tab in the navigation row?


<?php 
// Sub Navigation for product categories for orientation. Brace yourself! (modify at your own risk)
//only run the foreach if categories were found
?>
<div class="SubCatNav">
	
		
	<?php
	$orderby 	= $OPTION['wps_catSubNav_orderbyOption'];
	$order 		= $OPTION['wps_catSubNav_orderOption'];
	
	if (!empty($childrenCats)) {
		$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->term_id.'&hide_empty=0&style=none')),0,-6));
	#}elseif((empty($childrenCats)) && ($this_category->category_parent!=0)) {
		#$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->term_id.'&hide_empty=0&style=none')),0,-6));
	} else {
		$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->parent.'&hide_empty=0&style=none&depth=1')),0,-6));
	}	
	
	
	//only run the foreach if categories were found
	if (trim($cats[0]) != 'No cate') {  
		//how many rows?
		$wanted_rows	= $OPTION['wps_catSubNav_rows'];
		$num			= count($cats);
		$counter		= 1;			
		$container 		= '<ul>';
		
		foreach($cats as $cat){
			//set an active class on the current category				
			$parts1 = explode("</a>",$cat);						
			$parts2 = explode(">",$parts1[0]);
			$catnam	= trim($parts2[1]);	
			$the_li_class = ($this_category->name == $catnam ? 'active' : NULL);
			
			if($counter % $wanted_rows == 0){
				$container .= "<li class='$the_li_class'>".$cat .'</li></ul><ul>';					
			} else {
				$container .= "<li class='$the_li_class'>".$cat.'</li>';
			}
			
			$counter++;
		}
		wp_reset_query();
		
		$ending = substr($container,-4);
		if($ending == '<ul>'){
			$container = substr($container,0,-4);
		}
		
		echo $container;
	} ?>
	<ul class="viewAll">
		<?php if (!empty($childrenCats)) { ?>
			<li class="active"><a href="<?php echo get_category_link($this_category->term_id);?>"><?php _e('view all','wpShop');?></a></li>
		<?php #} elseif((empty($childrenCats)) && ($this_category->category_parent!=0)) { ?>
			<!--<li class="active"><a href="<?php echo get_category_link($this_category->term_id);?>"><?php _e('view all','wpShop');?></a></li>-->
		<?php } else { ?>
			<li><a href="<?php echo get_category_link($this_category->parent);?>"><?php _e('view all','wpShop');?></a></li>
		<?php } ?>
	</ul>
</div><!--end "Sub Navigation" section-->
<p style="float:left;margin-top:-20px;margin-left:20px;">Click image to 
 details:</p>

Open in new window

0
 

Author Comment

by:carolsanjose
ID: 35426557
Let me explain further...

On this parent category page (tile gallery) we want the opening page to not be "view all" but the 1st child category listed in the navigation.  On this page the 1st child category is new tiles.

How do I make 1st child category the active landing page when the parent category is showing?
http://66.147.244.225/~minimosa/category/tile-gallery/
0
 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 35426661
Try using the following code:
<?php 
// Sub Navigation for product categories for orientation. Brace yourself! (modify at your own risk)
//only run the foreach if categories were found
?>
<div class="SubCatNav">
	
		
	<?php
	$orderby 	= $OPTION['wps_catSubNav_orderbyOption'];
	$order 		= $OPTION['wps_catSubNav_orderOption'];
	
	if (!empty($childrenCats)) {
		$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->term_id.'&hide_empty=0&style=none')),0,-6));
	#}elseif((empty($childrenCats)) && ($this_category->category_parent!=0)) {
		#$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->term_id.'&hide_empty=0&style=none')),0,-6));
	} else {
		$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->parent.'&hide_empty=0&style=none&depth=1')),0,-6));
	}	
	
	
	//only run the foreach if categories were found
	if (trim($cats[0]) != 'No cate') {  
		//how many rows?
		$wanted_rows	= $OPTION['wps_catSubNav_rows'];
		$num			= count($cats);
		$counter		= 1;			
		$container 		= '<ul>';
		$firstTab = true;
		
		foreach($cats as $cat){
			//set an active class on the current category				
			$parts1 = explode("</a>",$cat);						
			$parts2 = explode(">",$parts1[0]);
			$catnam	= trim($parts2[1]);
			$the_li_class = ($firstTab ? 'active' : NULL);
		
			if($counter % $wanted_rows == 0){
				$container .= "<li class='$the_li_class'>".$cat .'</li></ul><ul>';					
			} else {
				$container .= "<li class='$the_li_class'>".$cat.'</li>';
			}
			
			$firstTab = false;
			$counter++;
		}
		wp_reset_query();
		
		$ending = substr($container,-4);
		if($ending == '<ul>'){
			$container = substr($container,0,-4);
		}
		
		echo $container;
	} ?>
	<ul class="viewAll">
		<?php if (!empty($childrenCats)) { ?>
			<li class="active"><a href="<?php echo get_category_link($this_category->term_id);?>"><?php _e('view all','wpShop');?></a></li>
		<?php #} elseif((empty($childrenCats)) && ($this_category->category_parent!=0)) { ?>
			<!--<li class="active"><a href="<?php echo get_category_link($this_category->term_id);?>"><?php _e('view all','wpShop');?></a></li>-->
		<?php } else { ?>
			<li><a href="<?php echo get_category_link($this_category->parent);?>"><?php _e('view all','wpShop');?></a></li>
		<?php } ?>
	</ul>
</div><!--end "Sub Navigation" section-->
<p style="float:left;margin-top:-20px;margin-left:20px;">Click image to 
 details:</p>

Open in new window

0
 

Author Comment

by:carolsanjose
ID: 35426860
I added the code above & this is what it looks like now:
http://66.147.244.225/~minimosa/category/tile-gallery/

What else to I need to tweak to make the view all tab not active?
0
 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 35426887
Try the following:
<?php 
// Sub Navigation for product categories for orientation. Brace yourself! (modify at your own risk)
//only run the foreach if categories were found
?>
<div class="SubCatNav">
	
		
	<?php
	$orderby 	= $OPTION['wps_catSubNav_orderbyOption'];
	$order 		= $OPTION['wps_catSubNav_orderOption'];
	
	if (!empty($childrenCats)) {
		$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->term_id.'&hide_empty=0&style=none')),0,-6));
	#}elseif((empty($childrenCats)) && ($this_category->category_parent!=0)) {
		#$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->term_id.'&hide_empty=0&style=none')),0,-6));
	} else {
		$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->parent.'&hide_empty=0&style=none&depth=1')),0,-6));
	}	
	
	
	//only run the foreach if categories were found
	if (trim($cats[0]) != 'No cate') {  
		//how many rows?
		$wanted_rows	= $OPTION['wps_catSubNav_rows'];
		$num			= count($cats);
		$counter		= 1;			
		$container 		= '<ul>';
		$firstTab = true;
		
		foreach($cats as $cat){
			//set an active class on the current category				
			$parts1 = explode("</a>",$cat);						
			$parts2 = explode(">",$parts1[0]);
			$catnam	= trim($parts2[1]);
			$the_li_class = ($firstTab ? 'active' : NULL);
		
			if($counter % $wanted_rows == 0){
				$container .= "<li class='$the_li_class'>".$cat .'</li></ul><ul>';					
			} else {
				$container .= "<li class='$the_li_class'>".$cat.'</li>';
			}
			
			$firstTab = false;
			$counter++;
		}
		wp_reset_query();
		
		$ending = substr($container,-4);
		if($ending == '<ul>'){
			$container = substr($container,0,-4);
		}
		
		echo $container;
	} ?>
	<ul class="viewAll">
		<?php if (!empty($childrenCats)) { ?>
			<li><a href="<?php echo get_category_link($this_category->term_id);?>"><?php _e('view all','wpShop');?></a></li>
		<?php #} elseif((empty($childrenCats)) && ($this_category->category_parent!=0)) { ?>
			<!--<li class="active"><a href="<?php echo get_category_link($this_category->term_id);?>"><?php _e('view all','wpShop');?></a></li>-->
		<?php } else { ?>
			<li><a href="<?php echo get_category_link($this_category->parent);?>"><?php _e('view all','wpShop');?></a></li>
		<?php } ?>
	</ul>
</div><!--end "Sub Navigation" section-->
<p style="float:left;margin-top:-20px;margin-left:20px;">Click image to 
 details:</p>

Open in new window

0
 

Author Comment

by:carolsanjose
ID: 35426982
We are getting there...thank you for your help.
Here is what it looks like after I added the code above:
http://66.147.244.225/~minimosa/category/tile-gallery/

Now, when I click on another tab, the active tab is not moving to reflect the current category.

What do I need to do to fix this?
0
 

Author Comment

by:carolsanjose
ID: 35427007
Actually, the active 1st tab is not displaying the proper category results. The new tiles tab is showing the tile galllery category, not the new tiles category.

When the first tab is highlighted, I want that category's results to show below.

0
 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 35427029

<?php 
// Sub Navigation for product categories for orientation. Brace yourself! (modify at your own risk)
//only run the foreach if categories were found
?>
<div class="SubCatNav">
	
		
	<?php
	$orderby 	= $OPTION['wps_catSubNav_orderbyOption'];
	$order 		= $OPTION['wps_catSubNav_orderOption'];
	
	if (!empty($childrenCats)) {
		$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->term_id.'&hide_empty=0&style=none')),0,-6));
	#}elseif((empty($childrenCats)) && ($this_category->category_parent!=0)) {
		#$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->term_id.'&hide_empty=0&style=none')),0,-6));
	} else {
		$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->parent.'&hide_empty=0&style=none&depth=1')),0,-6));
	}	
	
	
	//only run the foreach if categories were found
	if (trim($cats[0]) != 'No cate') {  
		//how many rows?
		$wanted_rows	= $OPTION['wps_catSubNav_rows'];
		$num			= count($cats);
		$counter		= 1;			
		$container 		= '<ul>';
		$firstTab = true;
		
		foreach($cats as $cat){
			//set an active class on the current category				
			$parts1 = explode("</a>",$cat);						
			$parts2 = explode(">",$parts1[0]);
			$catnam	= trim($parts2[1]);
			if ($catnam != '')
			{
				$the_li_class = ($this_category->name == $catnam ? 'active' : NULL);
			} else {
				if ($firstTab)
					$the_li_class = 'active';
			}
			if($counter % $wanted_rows == 0){
				$container .= "<li class='$the_li_class'>".$cat .'</li></ul><ul>';					
			} else {
				$container .= "<li class='$the_li_class'>".$cat.'</li>';
			}
			
			$firstTab = false;
			$counter++;
		}
		wp_reset_query();
		
		$ending = substr($container,-4);
		if($ending == '<ul>'){
			$container = substr($container,0,-4);
		}
		
		echo $container;
	} ?>
	<ul class="viewAll">
		<?php if (!empty($childrenCats)) { ?>
			<li><a href="<?php echo get_category_link($this_category->term_id);?>"><?php _e('view all','wpShop');?></a></li>
		<?php #} elseif((empty($childrenCats)) && ($this_category->category_parent!=0)) { ?>
			<!--<li class="active"><a href="<?php echo get_category_link($this_category->term_id);?>"><?php _e('view all','wpShop');?></a></li>-->
		<?php } else { ?>
			<li><a href="<?php echo get_category_link($this_category->parent);?>"><?php _e('view all','wpShop');?></a></li>
		<?php } ?>
	</ul>
</div><!--end "Sub Navigation" section-->
<p style="float:left;margin-top:-20px;margin-left:20px;">Click image to 
 details:</p>

Open in new window

0
 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 35427042
If you still have a problem please post your full code so I can help you better.
0
 

Author Comment

by:carolsanjose
ID: 35427116
I added your code above & this is what I get:
http://66.147.244.225/~minimosa/category/tile-gallery/

There is no active tab.

Maybe it not possible what I am trying to do.

In a nutshell, I want the parent category page to display navigation for child categories, starting with the first category only showing in the results...not the view all results for that category.

I am going to close the question because I don't feel like we are getting there.  Maybe what I am trying to do is not possible in wordpress loop.
0
 

Author Comment

by:carolsanjose
ID: 35427176
One more thing & I am ready to accept your answer & give you an A!

I'll use the code above which gives me this result:
http://66.147.244.225/~minimosa/category/tile-gallery/

GOOD - when I click on new tiles or abstract, the tab remains active.
BAD - the view all tab does not remain active after I click on it.

How do I make the view all tab work as active after it is clicked on?

Thanks for your patience & help!
0
 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 35427204
@carolsanjose: What you are trying to do is absolutely possible, however I am editing the code and posting here without doing any test.

If you could post the full code I will test it and give you the final code.
0
 

Author Comment

by:carolsanjose
ID: 35427315
Above, we have been working on the code in the includes files called categorysubnav.php.
Here is the code to the category page.

<?php
 
//collect options
$WPS_prodCol		= $OPTION['wps_prodCol_option'];
$WPS_catCol			= $OPTION['wps_catCol_option'];
$WPS_sidebar		= $OPTION['wps_sidebar_option'];
$WPS_showposts		= $OPTION['wps_showpostsOverwrite_Option'];

$this_category 		= get_category($cat);
$topParent 			= NWS_get_root_category($cat,'allData');
$topParentSlug 		= $topParent->slug;
$this_categorySlug 	= $this_category->slug;

//collect options
$orderBy 	= $OPTION['wps_secondaryCat_orderbyOption'];
$order 		= $OPTION['wps_secondaryCat_orderOption'];

//collect the child categories
$childrenCats 	= get_terms('category', 'orderby='.$orderBy.'&order='.$order.'&parent='.$this_category->term_id.'&hide_empty=0');

//collect the grandchild categories
foreach ($childrenCats as $childrenCat) {
	$currentChildCat 	= $childrenCat->term_id;
	$grandChildCats = get_terms('category', 'orderby='.$orderBy.'&order='.$order.'&parent='.$currentChildCat.'&hide_empty=0');
	$grandNum = count($grandChildCats);
	if ($grandNum > 0) {
		$grandChildCats = TRUE;
	break;
	} else {
		$grandChildCats = FALSE;
	}
}

// sidebar location?
switch($WPS_sidebar){
	case 'alignRight':
		$the_float_class 	= 'alignleft';
	break;
	case 'alignLeft':
		$the_float_class 	= 'alignright';
	break;
}
// teaser?
if($OPTION['wps_teaser_enable_option']) {$the_eqcol_class = 'eqcol'; }

//what cat column option?
switch($WPS_catCol){
	case 'catCol3':
		$catCol_class = 'theCats3';
	break;
		
	case 'catCol4':
		$catCol_class = 'theCats4';
	break;
}

//what prod column option?
switch($WPS_prodCol){
	case 'prodCol1':
		$prodCol_class = 'theProds1';
	break;
	case 'prodCol2':
		$prodCol_class = 'theProds2';
	break;
	case 'prodCol3':
		$prodCol_class = 'theProds3';
	break;
	case 'prodCol4':
		$prodCol_class = 'theProds4';
	break;
	case 'prodCol5':
		$prodCol_class = 'theProds5';
	break;
}

//set the div class	
if (!empty($childrenCats)) {
	
	if ($grandChildCats) {
		$the_div_class 	= 'theCats clearfix '.$catCol_class. ' '.$the_float_class;
	} else {
		$the_div_class 	= 'theProds clearfix '.$prodCol_class. ' '.$the_float_class.' '.$the_eqcol_class;
	}
	
	
} else {
	$the_div_class 	= 'theProds clearfix '.$prodCol_class. ' '.$the_float_class.' '.$the_eqcol_class;
} 
	
	if($OPTION['wps_catDescr_enable']) {
		echo term_description();
	} ?>

	<div class="<?php echo $the_div_class;?>">
		<?php 
		//display subcategories if my category has children, otherwise display products. Display also products when there's no grandchildren!
	
		if (!empty($childrenCats)) {
		
			if ($grandChildCats) {
				include (TEMPLATEPATH . '/includes/category/categoryDisplay.php');
			} else {
				include (TEMPLATEPATH . '/includes/category/productDisplay.php');
			}
			
		} 
		//otherwise display products
		else {
			include (TEMPLATEPATH . '/includes/category/productDisplay.php');
		} ?>
	<br/>
	<br/>		
	</div><!-- theProds -->
<?php if ($WPS_prodCol != 'prodCol5') { ?>
	</div><!-- main_col -->			
<?php }
	
	if ($WPS_prodCol != 'prodCol5') {
		include (TEMPLATEPATH . '/widget_ready_areas.php');
	}
get_footer(); ?>

Open in new window

0
 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 35427492
The function 'get_category()' is missing, do you include from another script and you missed posting it here?

Something important, I want to know the variable '$catnam'.

Please use the following code and let me know so I will check the page to see the variable '$catnam' contents.
<?php 
// Sub Navigation for product categories for orientation. Brace yourself! (modify at your own risk)
//only run the foreach if categories were found
?>
<div class="SubCatNav">
	
		
	<?php
	$orderby 	= $OPTION['wps_catSubNav_orderbyOption'];
	$order 		= $OPTION['wps_catSubNav_orderOption'];
	
	if (!empty($childrenCats)) {
		$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->term_id.'&hide_empty=0&style=none')),0,-6));
	#}elseif((empty($childrenCats)) && ($this_category->category_parent!=0)) {
		#$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->term_id.'&hide_empty=0&style=none')),0,-6));
	} else {
		$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->parent.'&hide_empty=0&style=none&depth=1')),0,-6));
	}	
	
	
	//only run the foreach if categories were found
	if (trim($cats[0]) != 'No cate') {  
		//how many rows?
		$wanted_rows	= $OPTION['wps_catSubNav_rows'];
		$num			= count($cats);
		$counter		= 1;			
		$container 		= '<ul>';
		$firstTab = true;
		
		foreach($cats as $cat){
			//set an active class on the current category				
			$parts1 = explode("</a>",$cat);						
			$parts2 = explode(">",$parts1[0]);
			$catnam	= trim($parts2[1]);
			if ($catnam != '')
			{
				$the_li_class = ($this_category->name == $catnam ? 'active' : NULL);
			} else {
				if ($firstTab)
					$the_li_class = 'active';
			}
			echo "BEGIN VAR<br />";
			echo "$counter: $catnam" . "<br /><br />";
			echo "END VAR";
			if($counter % $wanted_rows == 0){
				$container .= "<li class='$the_li_class'>".$cat .'</li></ul><ul>';					
			} else {
				$container .= "<li class='$the_li_class'>".$cat.'</li>';
			}
			
			$firstTab = false;
			$counter++;
		}
		wp_reset_query();
		
		$ending = substr($container,-4);
		if($ending == '<ul>'){
			$container = substr($container,0,-4);
		}
		
		echo $container;
	} ?>
	<ul class="viewAll">
		<?php if (!empty($childrenCats)) { ?>
			<li><a href="<?php echo get_category_link($this_category->term_id);?>"><?php _e('view all','wpShop');?></a></li>
		<?php #} elseif((empty($childrenCats)) && ($this_category->category_parent!=0)) { ?>
			<!--<li class="active"><a href="<?php echo get_category_link($this_category->term_id);?>"><?php _e('view all','wpShop');?></a></li>-->
		<?php } else { ?>
			<li><a href="<?php echo get_category_link($this_category->parent);?>"><?php _e('view all','wpShop');?></a></li>
		<?php } ?>
	</ul>
</div><!--end "Sub Navigation" section-->
<p style="float:left;margin-top:-20px;margin-left:20px;">Click image to 
 details:</p>

Open in new window

0
 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 35427706
I have posted objection since I am helping you here and I need some information as I said above so I can give you better solution.
0
 

Author Comment

by:carolsanjose
ID: 35427794
Here is what I got when I added your code above.
http://66.147.244.225/~minimosa/category/tile-gallery/

I am ready to finish this...I don't think we are getting there.

THis Wordpress theme & template is complicated and I think I am asking you to do something that is not possible.


Can we end this question now?
0
 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 35428009
From my experience your question can be solved, so I think it's better to end the question with its solution to help other people who are searching for similar solutions.

I have updated the code.
<?php 
// Sub Navigation for product categories for orientation. Brace yourself! (modify at your own risk)
//only run the foreach if categories were found
?>
<div class="SubCatNav">
	
		
	<?php
	$orderby 	= $OPTION['wps_catSubNav_orderbyOption'];
	$order 		= $OPTION['wps_catSubNav_orderOption'];
	
	if (!empty($childrenCats)) {
		$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->term_id.'&hide_empty=0&style=none')),0,-6));
	#}elseif((empty($childrenCats)) && ($this_category->category_parent!=0)) {
		#$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->term_id.'&hide_empty=0&style=none')),0,-6));
	} else {
		$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->parent.'&hide_empty=0&style=none&depth=1')),0,-6));
	}	
	
	
	//only run the foreach if categories were found
	if (trim($cats[0]) != 'No cate') {  
		//how many rows?
		$wanted_rows	= $OPTION['wps_catSubNav_rows'];
		$num			= count($cats);
		$counter		= 1;			
		$container 		= '<ul>';
		$tabSpecified = false;
		
		foreach($cats as $cat) {
			//set an active class on the current category				
			$parts1 = explode("</a>",$cat);						
			$parts2 = explode(">",$parts1[0]);
			$catnam	= trim($parts2[1]);
			if ($this_category->name == $catnam)
			{
				$tabSpecified = true;
				break;
			}
		}
	
		foreach($cats as $cat) {
			//set an active class on the current category				
			$parts1 = explode("</a>",$cat);						
			$parts2 = explode(">",$parts1[0]);
			$catnam	= trim($parts2[1]);
			if ($tabSpecified)
			{
				$the_li_class = ($this_category->name == $catnam ? 'active' : NULL);
			} else {
				if ($counter == 0)
					$the_li_class = 'active';
			}
			if($counter % $wanted_rows == 0){
				$container .= "<li class='$the_li_class'>".$cat .'</li></ul><ul>';
			} else {
				$container .= "<li class='$the_li_class'>".$cat.'</li>';
			}
			
			$firstTab = false;
			$counter++;
		}
		wp_reset_query();
		
		$ending = substr($container,-4);
		if($ending == '<ul>'){
			$container = substr($container,0,-4);
		}
		
		echo $container;
	} ?>
	<ul class="viewAll">
		<?php if (!empty($childrenCats)) { ?>
			<li><a href="<?php echo get_category_link($this_category->term_id);?>"><?php _e('view all','wpShop');?></a></li>
		<?php #} elseif((empty($childrenCats)) && ($this_category->category_parent!=0)) { ?>
			<!--<li class="active"><a href="<?php echo get_category_link($this_category->term_id);?>"><?php _e('view all','wpShop');?></a></li>-->
		<?php } else { ?>
			<li><a href="<?php echo get_category_link($this_category->parent);?>"><?php _e('view all','wpShop');?></a></li>
		<?php } ?>
	</ul>
</div><!--end "Sub Navigation" section-->
<p style="float:left;margin-top:-20px;margin-left:20px;">Click image to 
 details:</p>

Open in new window

0
 

Author Comment

by:carolsanjose
ID: 35428321
I added the code above.
Now this is what I get:

How do I make the View all  tab stay highlighted when I click on that tab?  Right now it stays grey.

http://66.147.244.225/~minimosa/category/tile-gallery/
0
 

Author Comment

by:carolsanjose
ID: 35428329

Is there something in this code change that would affect our front page slide show?  Right now it is opening really slowly.

http://66.147.244.225/~minimosa/
0
 
LVL 12

Accepted Solution

by:
Mohamed Abowarda earned 2000 total points
ID: 35428425
I don't think that there is anything with the code that slow down the main page, anyway, I made another update, hope that work for you:
<?php
// Sub Navigation for product categories for orientation. Brace yourself! (modify at your own risk)
//only run the foreach if categories were found
?>
<div class="SubCatNav">
	
		
	<?php
	$orderby 	= $OPTION['wps_catSubNav_orderbyOption'];
	$order 		= $OPTION['wps_catSubNav_orderOption'];
	
	if (!empty($childrenCats)) {
		$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->term_id.'&hide_empty=0&style=none')),0,-6));
	#}elseif((empty($childrenCats)) && ($this_category->category_parent!=0)) {
		#$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->term_id.'&hide_empty=0&style=none')),0,-6));
	} else {
		$cats = explode("<br />",substr(trim(wp_list_categories('title_li=&echo=0&orderby='.$orderby.'&order='.$order.'&child_of='.$this_category->parent.'&hide_empty=0&style=none&depth=1')),0,-6));
	}	
	
	
	//only run the foreach if categories were found
	if (trim($cats[0]) != 'No cate') {  
		//how many rows?
		$wanted_rows	= $OPTION['wps_catSubNav_rows'];
		$num			= count($cats);
		$counter		= 1;			
		$container 		= '<ul>';
		$tabSelected = false;
		
		foreach($cats as $cat) {
			//set an active class on the current category				
			$parts1 = explode("</a>",$cat);						
			$parts2 = explode(">",$parts1[0]);
			$catnam	= trim($parts2[1]);
			if ($this_category->name == $catnam)
			{
				$the_li_class = 'active';
				$tabSelected = true;
			}
			if($counter % $wanted_rows == 0){
				$container .= "<li class='$the_li_class'>".$cat .'</li></ul><ul>';
			} else {
				$container .= "<li class='$the_li_class'>".$cat.'</li>';
			}
			
			$firstTab = false;
			$counter++;
		}
		if (!$tabSelected)
			header("location: ../../category/tile-gallery/new-tiles/");
		wp_reset_query();
		
		$ending = substr($container,-4);
		if($ending == '<ul>'){
			$container = substr($container,0,-4);
		}
		
		echo $container;
	} ?>
	<ul class="viewAll">
		<?php if (!empty($childrenCats)) { ?>
			<li><a href="<?php echo get_category_link($this_category->term_id);?>"><?php _e('view all','wpShop');?></a></li>
		<?php #} elseif((empty($childrenCats)) && ($this_category->category_parent!=0)) { ?>
			<!--<li class="active"><a href="<?php echo get_category_link($this_category->term_id);?>"><?php _e('view all','wpShop');?></a></li>-->
		<?php } else { ?>
			<li><a href="<?php echo get_category_link($this_category->parent);?>"><?php _e('view all','wpShop');?></a></li>
		<?php } ?>
	</ul>
</div><!--end "Sub Navigation" section-->
<p style="float:left;margin-top:-20px;margin-left:20px;">Click image to 
 details:</p>

Open in new window

0
 

Author Comment

by:carolsanjose
ID: 35428678
I added the code you listed above.
Take a look:
http://66.147.244.225/~minimosa/category/tile-gallery/

I am ready to close the question now.

0
 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 35711518
I recommend closing this question by accepting http:#35420835
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question