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

0 Members and 1 Guest are viewing this topic.

Offline iraklis

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: [MOD] limited number of categories per page
« Reply #45 on: August 09, 2005, 02:09:16 PM »
could someone send me his "funktion.php" ???  :mrgreen:

TheOracle

  • Guest
Re: [MOD] limited number of categories per page
« Reply #46 on: August 09, 2005, 02:09:39 PM »
Quote

foreach ($visible_cat_cache as $key => $category_id) {


That is the original coding.

The instructions says :

Quote

foreach ($cache as $category_id) {


And now, replace it with :

Code: [Select]

foreach ($visible_cat_cache as $category_id) {


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 #47 on: August 09, 2005, 02:14:12 PM »
Quote

foreach ($visible_cat_cache as $key => $category_id) {


That is the original coding.

The instructions says :

Quote

foreach ($cache as $category_id) {


And now, replace it with :

Code: [Select]

foreach ($visible_cat_cache as $category_id) {


Please! u dont know what u are talking about, period!

@iraklis:
please show the block of code started from line:
Code: [Select]
function get_categories($cat_id = 0) {and ended with:
Code: [Select]
function get_category_path($cat_id = 0, $detail_path = 0) {
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 #48 on: August 09, 2005, 02:16:22 PM »
Code: [Select]
function get_categories($cat_id = 0) {
  global $site_template, $site_db, $site_sess, $config, $lang, $HTTP_GET_VARS;
  global $cat_cache, $cat_parent_cache, $new_image_cache, $subcat_ids;

  $cattable_width = ceil((intval($config['cat_table_width'])) / $config['cat_cells']);
  if ((substr($config['cat_table_width'],-1)) == "%") {
    $cattable_width .= "%";
  }

  if (!isset($cat_parent_cache[$cat_id])) {
    return "";
  }

  $visible_cat_cache = array();
  foreach ($cat_parent_cache[$cat_id] as $key => $val) {
    if (check_permission("auth_viewcat", $val)) {
      $visible_cat_cache[$key] = $val;
    }
  }

  if (empty($visible_cat_cache)) {
    return "";
  }

$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 $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

  $table_columns = (intval($config['cat_cells'])) ? intval($config['cat_cells']) : 2;
  if ($total <= $table_columns) {
    $table_rows = 1;
  }
  else {
    $table_rows = $total / $table_columns;
    if ($total >= $table_columns && !is_integer($table_rows)) {
      $table_rows = intval($table_rows) + 1;
    }
  }

  $categories = "\n<table width=\"".$config['cat_table_width']."\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n<tr>\n<td valign=\"top\" width=\"".$cattable_width."\" class=\"catbgcolor\">\n";
  $categories .= "<table border=\"0\" cellpadding=\"".$config['cat_table_cellpadding']."\" cellspacing=\"".$config['cat_table_cellspacing']."\">\n";
  $count = 0;
  $count2 = 0;
  foreach ($cache as $category_id){
    $categories .= "<tr>\n<td valign=\"top\">\n";

    $is_new = (isset($new_image_cache[$category_id]) && $new_image_cache[$category_id] > 0) ? 1 : 0;
    $num_images = (isset($cat_cache[$category_id]['num_images'])) ? $cat_cache[$category_id]['num_images'] : 0;

    $subcat_ids = array();
    get_subcat_ids($category_id, $category_id, $cat_parent_cache);

    if (isset($subcat_ids[$category_id])) {
      foreach ($subcat_ids[$category_id] as $val) {
        if (isset($new_image_cache[$val]) && $new_image_cache[$val] > 0) {
          $is_new = 1;
        }
        if (isset($cat_cache[$val]['num_images'])) {
          $num_images += $cat_cache[$val]['num_images'];
        }
      }
    }

    if (defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0 || defined("SHOW_RANDOM_CAT_IMAGE") && SHOW_RANDOM_CAT_IMAGE == 0) {
      $random_cat_image_file = "";
    }
    else {
      $random_cat_image_file = get_random_image($category_id, 0, 1);
    }

 
    if ($categories && function_exists('get_subcategories') && $num_images >= 1) {
 
    $site_template->register_vars(array(
      "cat_id" => $category_id,
      "cat_name" => $cat_cache[$category_id]['cat_name'],
      "cat_description" => $cat_cache[$category_id]['cat_description'],
      "cat_hits" => $cat_cache[$category_id]['cat_hits'],
      "cat_is_new" => $is_new,
      "lang_new" => $lang['new'],
      "sub_cats" => get_subcategories($category_id),
      "cat_url" => $site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$category_id),
      "random_cat_image_file" => $random_cat_image_file,
      "num_images" => $num_images
    ));
   
    $categories .= $site_template->parse_template("category_bit");
    $count++;
    $count2++;
    $categories .= "</td>\n</tr>\n";
   
    } ####### End of if statement.

    if ($count == $table_rows && $count2 < sizeof($visible_cat_cache)) {
      $categories .= "</table></td>\n";
      $categories .= "<td valign=\"top\" width=\"".$cattable_width."\" class=\"catbgcolor\">\n";
      $categories .= "<table border=\"0\" cellpadding=\"".$config['cat_table_cellpadding']."\" cellspacing=\"".$config['cat_table_cellspacing']."\">\n";

      $total = $total - $count2;
      $table_columns = $table_columns - 1;
      /*if ($total <= $table_columns && $table_columns > 1) {
        $table_rows = 1;
      }
      else {
        $table_rows = $total / $table_columns;
        if ($total >= $table_columns && !is_integer($table_rows)) {
          $table_rows = intval($table_rows) + 1;
        }
      }*/
      $count = 0;
    }
  }

  $categories .= "</table>\n</td>\n</tr>\n</table>\n";
  return $categories;
}

Offline iraklis

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: [MOD] limited number of categories per page
« Reply #49 on: August 09, 2005, 02:19:48 PM »
FYI

i also add this mod

http://www.4homepages.de/forum/index.php?topic=6675

but this souldn't disturb this one !?

TheOracle

  • Guest
Re: [MOD] limited number of categories per page
« Reply #50 on: August 09, 2005, 02:32:07 PM »
Quote

i also add this mod


Ah ! this wasn't mentionned first. ;)

Quote

but this souldn't disturb this one !?


If that MOD is related with the same functions as this one, it might become a problem due to a slight difference of codes.

Offline iraklis

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: [MOD] limited number of categories per page
« Reply #51 on: August 09, 2005, 02:37:36 PM »
in this mod you've just to configure the template category_bit.html. so don't think that this is the problem. i thought you know that with both mods combiend, there are problems. so it's not that

TheOracle

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

in this mod you've just to configure the template category_bit.html. so don't think that this is the problem. i thought you know that with both mods combiend, there are problems. so it's not that


I meant no disrespect. I was just making sure they had no conflicts. ;)

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 #53 on: August 09, 2005, 02:45:19 PM »
FYI

i also add this mod

http://www.4homepages.de/forum/index.php?topic=6675

but this souldn't disturb this one !?
no, it will not affect.

I just tested your code on a fresh 4images, the paging worked just fine, but no subcategories where showed because of
Code: [Select]
   if ($categories && function_exists('get_subcategories') && $num_images >= 1) {condition. (I dont know where this came from)


What happens if you insert above:
Code: [Select]
$total = sizeof($visible_cat_cache);this:
Code: [Select]
echo $cat_id."<br />";The idea it should show u the category id on top of the 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 #54 on: August 09, 2005, 03:00:26 PM »
it's 0

like the url: domain/categories.php?cat_id=0&cat_page=4

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 #55 on: August 09, 2005, 03:04:33 PM »
just to confirm, if you uinstall this mod, do u still get 0? (I have a feeling that 0 is what u'll get without this mod)

If so, then there is something wrong in your categories.php, perhaps other mods affecting
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 #56 on: August 09, 2005, 03:11:00 PM »
i upload the original categories.php, so that can't be the problem.

if i would write the url domain/categories.php?cat_id=3&cat_page=4 by my self. should it work? i tried it but it doesn't.

i also upload the original function.php and the cat_id is also 0

Offline iraklis

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: [MOD] limited number of categories per page
« Reply #57 on: August 09, 2005, 05:47:30 PM »
if i write this url in the browser domain/categories.php?cat_id=13&cat_page=2 i get the page with the pictures of categorie 13 and not the cat_page2. i don't know if it's normal!?


Offline iraklis

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: [MOD] limited number of categories per page
« Reply #58 on: August 10, 2005, 10:24:07 AM »
FYI
Quote
Step 3.
Add in /templates/<yourtemplate>/categories.html
those tags:
{cat_paging} and if u want {cat_paging_stats}


i didn't change the template categories.html, i changed the home.html. i don't know if this could be the problem!?

second thing
i took the original function.php modify it like it's written in the manual, but i've the same problem.

TheOracle

  • Guest
Re: [MOD] limited number of categories per page
« Reply #59 on: August 10, 2005, 04:43:22 PM »
Quote

i didn't change the template categories.html, i changed the home.html. i don't know if this could be the problem!?


In these circumstances, it must be done from categories.html and not home.html since no paging defaultly exists from home.html file.