Jump to content



Latest News: (loading..)

- - - - -

Spacing between parent categories (bm_categories)

spacing categories

  • Please log in to reply
1 reply to this topic

#1   wisekurt

wisekurt
  • Members
  • 4 posts
  • Real Name:Kurt

Posted 13 July 2012 - 05:48 AM

I noticed a few people ask about this, and unless i am missing something really obvious there is no simple way to edit the spacing between the parent categories only.

This is only applicable when you have multiple parent categories and the whole menu is always expanded.

Issue: You have two parent categories with many sub-categories, you wish to have them always expanded in the menu, however the parent categories from the second and lower have no upper margin/padding and touch up against the last subcategory.
Fix: Place a <p> with line height above ONLY the parent categories in the loop.

bm_categories.php v2.3.1

Modified code:
	function tep_show_category($counter) {
	  global $tree, $categories_string, $cPath_array;
	  for ($i=0; $i<$tree[$counter]['level']; $i++) {
		$categories_string .= "<p class='small'>";
	  }
  
   if (tep_has_category_subcategories($counter)) {
	  $categories_string .= '';
   }
  
	  if ($tree[$counter]['parent'] == 0) {
	$categories_string .= '<p style="line-height:10p;"></p><a href="';
		$cPath_new = 'cPath=' . $counter;
	  } else {
	$categories_string .= ' <a href="';
		$cPath_new = 'cPath=' . $tree[$counter]['path'];
	  }
  
The above is my modified code, however you can easily modify the original part that looks like the below:

Original code:
	
	function tep_show_category($counter) {
	  global $tree, $categories_string, $cPath_array;

	  for ($i=0; $i<$tree[$counter]['level']; $i++) {
		$categories_string .= "&nbsp;&nbsp;";
	  }

$categories_string .= '<a href="';

	  if ($tree[$counter]['parent'] == 0) {
		$cPath_new = 'cPath=' . $counter;
	  } else {
		$cPath_new = 'cPath=' . $tree[$counter]['path'];
	  }


Which will only modify your main categories, in my above code i have placed a <p></p> above each parent category, as if you have the categories expanded that second and below gets squished up into the above category.

There is a few ways to do this, although i hope this helps someone and isn't too confusing. I apologise for any sloppy coding or poor logic. Any questions welcome.

#2   al3ks

al3ks
  • Members
  • 288 posts
  • Real Name:Aleksander
  • Gender:Male
  • Location:UK

Posted 16 July 2012 - 12:00 AM

line-height:10p won't do anything. It should be line-height:10px
Find this post helpful? Click the 'Like this' button. :)