Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Limit Categoires Per Page


wshades

Recommended Posts

Posted

Title says it all...

 

Looking for a way to limit the categories are shown per page. I want 5 rows with 5 categories in each. I have the 5 across worked out just fine. But I need to limit the page and make it show a selector or page 2 and 3 and so on?

 

Anyone... please help.

Posted

To limit the numbe rof Sub Cats shown on the index page change

 

   	if ($categories['total'] < 1) {
     	// do nothing, go through the loop
   	} else {
     	$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");
     	break; // we've found the deepest category the customer is in
   	}
 	}
} else {
 	$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");
}

 

to

 

   	if ($categories['total'] < 1) {
     	// do nothing, go through the loop
   	} else {
     	$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name limit 20");
     	break; // we've found the deepest category the customer is in
   	}
 	}
} else {
 	$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name limit 20");
}

 

All we are doing is adding a limiter to the query "limit 20" right at the end, you can change the 20 to any number you like, even add an entry in your Databade to control it if you desire, the other you ask for is more involved than you think it might be, i suggest you have a play with the code, bear in mind ou will need to also edit the includes / classes / split_page_results.php file also.

 

Nic

 

 

Sometimes you're the dog and sometimes the lamp post

[/url]

My Contributions

Posted

Oh thanks soooo much for helping however I an not that good with the code. I found the changes to be made on the index page and made them with nothing happening as a result but you said I need to edit includes / classes / split_page_results.php file also.

 

But where on that page? I do not find something similar...

Posted

Oh thanks soooo much for helping however I an not that good with the code. I found the changes to be made on the index page and made them with nothing happening as a result but you said I need to edit includes / classes / split_page_results.php file also.

 

But where on that page? I do not find something similar...

 

The limit will limit how many sub cats to show, providing you have enough subcats.

If you want to add a next link this is when you will need to modify the split_page_results.php

Rgds

Nic

Sometimes you're the dog and sometimes the lamp post

[/url]

My Contributions

Posted

The limit will limit how many sub cats to show, providing you have enough subcats.

If you want to add a next link this is when you will need to modify the split_page_results.php

Rgds

Nic

 

Plus obviously add the code to the index.php file.

Nic

Sometimes you're the dog and sometimes the lamp post

[/url]

My Contributions

Posted

Nic,

 

First let thank you for your help.

 

I have modified the index page as you suggested adding the limit value where it is as close as I can find within the code.

---------------------------------------------------------

// check to see if there are deeper categories within the current category

$category_links = array_reverse($cPath_array);

for($i=0, $n=sizeof($category_links); $i<$n; $i++) {

$categories_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'");

$categories = tep_db_fetch_array($categories_query);

if ($categories['total'] < 1) {

// do nothing, go through the loop

} else {

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name limit 3");

break; // we've found the deepest category the customer is in

}

}

} else {

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name limit 3");

}

-------------------------------------------------------------------

What I am attempting to do is limit to 3 rows then go to next page ( split_page_results.php )

 

Is this accurate because I do not see the results happening on http://casa-bella.com/showroom/template/home.php?cPath=41%3E

 

I recognize that I have treated each granite subcategory as a product so the info (as seen in the example under "Baltic Brown" example ( http://casa-bella.com/showroom/template/home.php?cPath=41%3E )

 

I hope you can assist

Posted

Nic,

 

First let thank you for your help.

 

I have modified the index page as you suggested adding the limit value where it is as close as I can find within the code.

---------------------------------------------------------

// check to see if there are deeper categories within the current category

$category_links = array_reverse($cPath_array);

for($i=0, $n=sizeof($category_links); $i<$n; $i++) {

$categories_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'");

$categories = tep_db_fetch_array($categories_query);

if ($categories['total'] < 1) {

// do nothing, go through the loop

} else {

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name limit 3");

break; // we've found the deepest category the customer is in

}

}

} else {

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name limit 3");

}

-------------------------------------------------------------------

What I am attempting to do is limit to 3 rows then go to next page ( split_page_results.php )

 

Is this accurate because I do not see the results happening on http://casa-bella.com/showroom/template/home.php?cPath=41%3E

 

I recognize that I have treated each granite subcategory as a product so the info (as seen in the example under "Baltic Brown" example ( http://casa-bella.com/showroom/template/home.php?cPath=41%3E )

 

I hope you can assist

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...