Author Topic: [MOD] limited number of categories per page (updated 08-06-2006)  (Read 119480 times)

0 Members and 1 Guest are viewing this topic.

Offline Loet

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: [MOD] limited number of categories per page
« Reply #30 on: June 26, 2005, 09:24:27 PM »
V@no,

Everything fixed.
 :D Thanks again...

Loet

Loet van Oostende

Offline cneal

  • Pre-Newbie
  • Posts: 5
    • View Profile
Re: [MOD] limited number of categories per page
« Reply #31 on: June 27, 2005, 12:32:28 AM »
thanks! i was able to limit the number of catergories shown on my home.html page, but is there a way to add navigation for categories not shown on the home.html page? example: say i have 50 catergories and i want only 10 catergories diplayed on my home.html page. is there a way to add a link to the next page to display the next 10 catergories, etc.?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] limited number of categories per page
« Reply #32 on: June 27, 2005, 02:06:29 AM »
sorry, I dont think I understand your question.
This mod should affect home page as well as categories page....
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline iraklis

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: [MOD] limited number of categories per page
« Reply #33 on: August 08, 2005, 01:58:14 PM »
ok i read all the posts to this topic. i'm a little bit in disorder. i'm so far, that it shows the number of categories i want and the cat_paging. but i've still the problem  that i can't go to page number 2,3,4......

function.php looks like that

//Begin configuration:

$perpage = 3; //how many categories per page
$cat_text = "Found {total_cat_images} categories on {total_pages} page(s). Displayed category {first_page} to {last_page}";

//u can use those tags:
//{total_cat_images} - total categories
//{total_pages} - total pages
//{first_page} - displayed from (number first category displayed)
//{last_page} - displayed to (number last category displayed)
//End configuration

$page = (isset($HTTP_GET_VARS['cat_page'])) ? $HTTP_GET_VARS['cat_page'] : 0;
if (!class_exists(Paging)) {
include(ROOT_PATH.'includes/paging.php');
}
$link_arg = $site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id);
$getpaging = new Paging($page, $perpage, $total, $link_arg, $cat_text, "", "cat_page");
$offset = $getpaging->get_offset();
$limit = ($offset + $perpage > $total) ? $total : $offset + $perpage - 1;
$total = $limit - $offset;
$site_template->register_vars(array(
 "cat_paging" => $getpaging->get_paging(),
 "cat_paging_stats" => $getpaging->get_paging_stats()
));
$cache = array();
$i = 0;
foreach ($cache as $category_id){
if ($i >= $offset && $i <= $limit) {
$cache[] = $category_id;
   $cache_sql .= (($cache_sql != "") ? ", " : "").$category_id;
}
$i++;
}
$total = count($cache);


paging.php i've downloaded here http://gallery.vano.org/file18dl

so what could be wrong

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] limited number of categories per page
« Reply #34 on: August 08, 2005, 02:06:18 PM »
what do u see in the url to the page 2,3,4? do u use page=2 or do u see cat_page=2 ?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline iraklis

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: [MOD] limited number of categories per page
« Reply #35 on: August 08, 2005, 02:08:16 PM »
cat_page, i think i head also page, but i'm not shure. what's the wright one?

Offline iraklis

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: [MOD] limited number of categories per page
« Reply #36 on: August 08, 2005, 02:12:11 PM »
ok it should be cat_page, like it is.

is it correct like that
domain/categories.php?cat_id=0&cat_page=2

cat_id is everytime 0 is this correct?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] limited number of categories per page
« Reply #37 on: August 09, 2005, 12:26:22 AM »
ok it should be cat_page, like it is.

is it correct like that
domain/categories.php?cat_id=0&cat_page=2

cat_id is everytime 0 is this correct?
no, its not correct...
are you sure u inserted the code from step 1.2 in the correct place?
I just realized that the string u were supposed to find in that step was misspelled, instead of
Code: [Select]
  $total = count($visible_cat_cache); it was supposed to be
Code: [Select]
  $total = sizeof($visible_cat_cache);(the original post updated)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline iraklis

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: [MOD] limited number of categories per page
« Reply #38 on: August 09, 2005, 11:39:03 AM »
I changed what you wrote. But it doesn't work.

An other question, should this be like that?
  global $site_template, $site_db, $site_sess, $config, $lang, $HTTP_GET_VARS;
or like that
  global $site_template, $site_db, $site_sess, $config, $lang, $_GET;



TheOracle

  • Guest
Re: [MOD] limited number of categories per page
« Reply #39 on: August 09, 2005, 01:23:38 PM »
4images is fully based on superglobals, so it's this one :

Quote

global $site_template, $site_db, $site_sess, $config, $lang, $HTTP_GET_VARS;


;)

Offline iraklis

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: [MOD] limited number of categories per page
« Reply #40 on: August 09, 2005, 01:51:29 PM »
that isn't the problem. but what i found out:

with
Quote
foreach ($visible_cat_cache as $key => $category_id) {
it works and i see the categories, limited by the script.

with
Quote
foreach ($cache as $category_id){
i can't see the categories



TheOracle

  • Guest
Re: [MOD] limited number of categories per page
« Reply #41 on: August 09, 2005, 01:52:49 PM »
Quote

i can't see the categories


Correct. It has to stay with the $visible_cat_cache.

Offline iraklis

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: [MOD] limited number of categories per page
« Reply #42 on: August 09, 2005, 01:57:56 PM »
Quote
Correct. It has to stay with the $visible_cat_cache.

so why is in the manual step 1.3 written,

Quote
Find:
Code:
foreach ($visible_cat_cache as $key => $category_id) {
Replace with:
Code:
foreach ($cache as $category_id){

there is my code like it is now, is anything wrong? i can't see any fault. may be you

Code: [Select]
$total = sizeof($visible_cat_cache);

//Begin configuration:

$perpage = 3; //how many categories per page
$cat_text = "Found {total_cat_images} categories on {total_pages} page(s). Displayed category {first_page} to {last_page}";

//u can use those tags:
//{total_cat_images} - total categories
//{total_pages} - total pages
//{first_page} - displayed from (number first category displayed)
//{last_page} - displayed to (number last category displayed)
//End configuration

$page = (isset($HTTP_GET_VARS['cat_page'])) ? $HTTP_GET_VARS['cat_page'] : 0;
if (!class_exists(Paging)) {
include(ROOT_PATH.'includes/paging.php');
}
$link_arg = $site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id);
$getpaging = new Paging($page, $perpage, $total, $link_arg, $cat_text, "", "cat_page");
$offset = $getpaging->get_offset();
$limit = ($offset + $perpage > $total) ? $total : $offset + $perpage - 1;
$total = $limit - $offset;
$site_template->register_vars(array(
 "cat_paging" => $getpaging->get_paging(),
 "cat_paging_stats" => $getpaging->get_paging_stats()
));
$cache = array();
$i = 0;
foreach ($visible_cat_cache as $key => $category_id) {
if ($i >= $offset && $i <= $limit) {
$cache[] = $category_id;
   $cache_sql .= (($cache_sql != "") ? ", " : "").$category_id;
}
$i++;
}
$total = count($cache);
//END MOD category for each page

TheOracle

  • Guest
Re: [MOD] limited number of categories per page
« Reply #43 on: August 09, 2005, 02:05:44 PM »
Perhaps I missed something regarding this functionality but

replace :

Quote

foreach ($cache as $category_id){


with :

Code: [Select]

foreach ($visible_cat_cache as $category_id){


Offline iraklis

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: [MOD] limited number of categories per page
« Reply #44 on: August 09, 2005, 02:07:23 PM »
like you can see in the code, it is already done.