4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: dosensteck on October 23, 2005, 02:57:29 PM

Title: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: dosensteck on October 23, 2005, 02:57:29 PM
NOT MY MOD, FOUND IN GOOGLE CACHE! NO SUPPORT!
Mod Author: rproctor

PAGING PROBLEM GELÖST

You can go hee to my test site which I mess with code and what not. This is a direct link to a main category which has the master_cat turned on and this mod installed.

http://www.digitalgod.biz/test/categories.php?cat_id=4

I needed a way to better organize my categories. I didnt want my main categories to have any submissions, only my sub categories, but it looks so ugly when you view a main category and it says 0 images found. So, instead with a few tweeks, I made categories that I selected display the images of the subcategories.

The downfall is that if you select a category to display subcat images, it will only display FIRST LEVEL sub cat images. Also, if you upload an image where it is specified to show sub cat images, the image will now show up in the category, this is why you should only upload to sub cats that are not checked to disply subcat images. However, you can check sub cats to display sub cat images if that sub cat has a sub cat. Sub cat main cat blue cat green cat... Confused yet? Wink

1) First thing to do is create a field in the CATEGORIES_TABLE using a program like PHPMyAdmin. This field should be named cat_master and a type of tinyint(1), not null, and 0 for default.

2) Now, the boring part. Its time to edit the admin category file so that we can edit this field via ACP. Open admin/categories.php and find

Code: [Select]
  $cat_hits = intval(trim($HTTP_POST_VARS['cat_hits']));

Add after

Code: [Select]
  $cat_master = intval(trim($HTTP_POST_VARS['cat_master']));

2.1) find

Code: [Select]
            SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment

Replace with

Code: [Select]
            SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment, cat_master = $cat_master

2.2) find

Code: [Select]
  $sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment

Replace with

Code: [Select]
  $sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, cat_master

2.3) find

Code: [Select]
  show_input_row($lang['field_hits'], "cat_hits", $result['cat_hits'], 5);

add after

Code: [Select]
  show_radio_row("cat_master", "cat_master", $result['cat_master']);

2.4) find

Code: [Select]
  $sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment

Replace with

Code: [Select]
  $sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, cat_master
/
3) Now its time to make it work. Open 4images/categories.php and find

Code: [Select]
//-----------------------------------------------------
//--- Show Categories ---------------------------------
//-----------------------------------------------------

Add right before it

Code: [Select]
$sql = "SELECT cat_master
      FROM ".CATEGORIES_TABLE."
      WHERE cat_id = $cat_id";
$master_cat = $site_db->query_firstrow($sql);

3.1) Next find

Code: [Select]
"cat_name" => htmlspecialchars($cat_cache[$cat_id]['cat_name']),
Change to

Code: [Select]
"cat_name2" => htmlspecialchars($cat_cache[$cat_id]['cat_name']),
in 4images v1.7.6 find:
Code: [Select]
  "cat_name" => format_text($cat_cache[$cat_id]['cat_name'], 2),
Change to
Code: [Select]
  "cat_name2" => format_text($cat_cache[$cat_id]['cat_name'], 2),

3.2) Find

Code: [Select]
if (!$num_rows)  {
  $thumbnails = "";
  $msg = $lang['no_images'];
}

Replace with

Code: [Select]
if (!$num_rows)  {
  $thumbnails = "";
      if ($master_cat['cat_master'] == 1){
           $msg = "";
      }
      else{
           $msg = $lang['no_images'];
      }
}

3.3) Now find

Code: [Select]
$site_template->register_vars("thumbnails", $thumbnails);
unset($thumbnails);

Add below

Code: [Select]


//-----------------------------------------------------
//--- Show Sub Images ---------------------------------
//-----------------------------------------------------

if ($master_cat['cat_master'] == 1){



$sql = "SELECT cat_parent_id
        FROM ".CATEGORIES_TABLE."
      WHERE cat_parent_id = $cat_id";
$total_subs = $site_db->query($sql);
$num_subs = $site_db->get_numrows($total_subs);



$sql = "SELECT i.image_id, i.cat_id, i.image_active, c.cat_parent_id
        FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
        WHERE i.image_active = 1 AND c.cat_parent_id = $cat_id AND c.cat_id = i.cat_id";

$result2 = $site_db->query($sql);
$num_rows2 = $site_db->get_numrows($result2);


$link_arg = $site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id);

//include(ROOT_PATH.'includes/paging.php');
$getpaging = new Paging($page, $perpage, $num_rows2, $link_arg);
$offset = $getpaging->get_offset();


$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_parent_id, c.cat_name".get_user_table_field(", u.", "user_name")."
        FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
        LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
        WHERE i.image_active = 1 AND c.cat_parent_id = $cat_id AND c.cat_id = i.cat_id
        ORDER BY ".$config['image_order']." ".$config['image_sort']."
        LIMIT $offset, $perpage";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);


$imgtable_width = ceil((intval($config['image_table_width'])) / $config['image_cells']);
if ((substr($config['image_table_width'], -1)) == "%") {
  $imgtable_width .= "%";
}

$additional_sql = "";
if (!empty($additional_image_fields)) {
  foreach ($additional_image_fields as $key => $val) {
    $additional_sql .= ", i.".$key;
  }
}

if (!$num_rows)  {
  $thumbnails = "";
  $msg = $lang['no_images'];
}
else {
  $thumbnails = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">\n";
  $count = 0;
  $bgcounter = 0;
  while ($image_row = $site_db->fetch_array($result)){
    if ($count == 0) {
      $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
      $thumbnails .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    $thumbnails .= "<td width=\"".$imgtable_width."\"  =\"top\">\n";

    show_image($image_row);
    $thumbnails .= $site_template->parse_template("thumbnail_bit");
    $thumbnails .= "\n</td>\n";

    $count++;
    if ($count == $config['image_cells']) {
      $thumbnails .= "</tr>\n";
      $count = 0;
    }
  } // end while

  if ($count > 0)  {
    $leftover = ($config['image_cells'] - $count);
    if ($leftover > 0) {
      for ($i = 0; $i < $leftover; $i++){
        $thumbnails .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      $thumbnails .= "</tr>\n";
    }
  }
  $thumbnails .= "</table>\n";
} //end else
$site_template->register_vars("thumbnails", $thumbnails);
unset($thumbnails);
}

4) Here is the last and easiest part. Open 4images/templates/<your_template>/categories.php and change {cat_name} to {cat_name2}.

5) Now upload your edited files to your site. Next enter your ACP and select "Edit categories". You should notice a new field under hits called cat_master, change this to yes to enable this mod for that category. Dont forget, if you upload an image to that category and it has cat_master enabled that image will now show, so you should disable uploading for that category.

Thats about it, hope it works ok, I tested my own instructions on a new installation to make sure I did everything right, and it all seems to be ok.

DEMO: http://www.hobby-fotografen.com/categories.php?cat_id=19

ps: sorry for my bad english :/


so, habe das pagingproblem nun doch in den griff bekommen, und der mod funktioniert jetzt einwandfrei (vielleicht nicht sauber gecodet - funzt aber :D)


Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat.
Post by: Vincent on October 23, 2005, 04:07:25 PM
the Link in the TOP is not working and i got this error
----
Warning: mysql_connect(): Access denied for user: 'digital_tester@localhost' (Using password: YES) in /home/digital/public_html/test/includes/db_mysql.php on line 39

DB Error: Could not connect to the database server (localhost, digital_tester).

Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat.
Post by: dosensteck on October 23, 2005, 06:00:09 PM
the Link in the TOP is not working and i got this error
----
Warning: mysql_connect(): Access denied for user: 'digital_tester@localhost' (Using password: YES) in /home/digital/public_html/test/includes/db_mysql.php on line 39

DB Error: Could not connect to the database server (localhost, digital_tester).



ist from the originalpost from rproctor - i post a demolink to my site
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat.
Post by: dosensteck on October 31, 2005, 01:14:55 PM
hat vielleicht irgendjemand zeit sich das pagingproblem anzusehen? ich bin leider nicht der hellste in php und schon schwer daran verzweifelt :/

habe mir andere systeme angesehen wie die das machen - leider habe ich dadurch auch keine lösung gefunden :/

Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat.
Post by: dosensteck on November 02, 2005, 03:04:50 AM
hat vielleicht irgendjemand zeit sich das pagingproblem anzusehen? ich bin leider nicht der hellste in php und schon schwer daran verzweifelt :/

habe mir andere systeme angesehen wie die das machen - leider habe ich dadurch auch keine lösung gefunden :/




so, habe das pagingproblem nun doch in den griff bekommen, und der mod funktioniert jetzt einwandfrei (vielleicht nicht sauber gecodet - funzt aber :D)

allerdings funktioniert die linkreihenfolge nichtmehr richtig wenn man in der detailpage weiterblättert
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: Riser on November 09, 2005, 11:31:00 AM
Hi dosensteck,
seit Tagen versuche ich, diesen Mod zum laufen zu bringen, aber es will nicht funzen. :(

Im ACP erhalte ich beim Klick auf "Kategorien bearbeiten" folgende Fehlermeldung:

Parse error: parse error, unexpected T_STRING in /meinedomain/4images/admin/categories.php on line 513

Der Code sihet so aus (line 513 ist hier die Zeile '$sql = "SELECT cat_name, cat_description,...')

----

  if (empty($error)) {
    $sql = "UPDATE ".CATEGORIES_TABLE."
            $sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, cat_master
            show_radio_row("cat_master", "cat_master", $result['cat_master']);
    WHERE cat_id = $cat_id";
    $result = $site_db->query($sql);

    $msg = ($result) ? $lang['cat_edit_success'] : $lang['cat_edit_error'];
    $action = "modifycats";
  }
  else {
    $msg .= sprintf("<span class=\"marktext\">%s</span>", $lang['lostfield_error']);
    $action = "editcat";
  }
}

------

Bei der Ansicht der Cat.-Seiten selbst erhalte ich außerdem den Error:

Parse error: parse error, unexpected '{' in /meinedomain/4images/categories.php on line 128

Der Code sieht so aus (line 128 ist die erste Zeile dieses Abschnittes 'if (....'):

----

if (!$num_rows)  {
  $thumbnails = "";
      if ($master_cat['cat_master'] == 1){
           $msg = "";
      }
      else{
           $msg = $lang['no_images'];
      }
}

-----

Kannst du oder jemand sonst mir BITTE behilflich sein, kenne mich mit php leider sehr wenig aus und langsam verlier ich die Nerven. ;-)

Grüße
Riser

PS: Alles was ich will, ist die Darstellung der neusten Bilder auf den Cat.-Seiten, d.h. neuste Bilder in der jeweiligen Cat/Subcat. Gibts dafür nicht noch eine einfachere Lösung, müsste doch eigentlich Standart sein, oder?
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: dosensteck on November 12, 2005, 11:39:39 PM
habe den oberen code aktualisiert, jetzt müsste es funktionieren, war mein fehler! sorry für die umstände :(
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: ch€ri{Bi}² on November 13, 2005, 12:39:09 PM
Quote
Parse error: parse error, unexpected T_STRING in /meinedomain/4images/admin/categories.php on line 513

Der Code sihet so aus (line 513 ist hier die Zeile '$sql = "SELECT cat_name, cat_description,...')

----

  if (empty($error)) {
    $sql = "UPDATE ".CATEGORIES_TABLE."
            $sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, cat_master
            show_radio_row("cat_master", "cat_master", $result['cat_master']);
    WHERE cat_id = $cat_id";
    $result = $site_db->query($sql);

    $msg = ($result) ? $lang['cat_edit_success'] : $lang['cat_edit_error'];
    $action = "modifycats";
  }
  else {
    $msg .= sprintf("<span class=\"marktext\">%s</span>", $lang['lostfield_error']);
    $action = "editcat";
  }
}

the line indicated in red should not be written at this position  :roll:
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: dosensteck on November 17, 2005, 03:35:44 PM
ok, the paging works, the sub images show in the main cat


but, when i click a image the next and previous imagelink  is not corecct...  :?:

has anyone a idea? where is the code fot this part?
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: Riser on December 17, 2005, 05:11:48 PM
@dosensteck, scheint jetzt zu funktionieren. Vielen Dank, dass du dir die Mühe gemacht hast, deine Lösung hier nochmal zu posten. Du hast mir einen Riesengefallen getan. Entschuldige bitte mein spätes Reply, bin kurz nach meinem Post in Urlaub gefahren und hab mein Problem daher erstmal beiseite gelegt. Nochmals danke!

Gruß
Riser

PS: Juhuuuu! :D
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: Riser on December 17, 2005, 09:46:21 PM
@dosensteck, the previous/next-links work fine on my site but the paging didn't, so I've added one little thing and now it works. Here is what I did:


3.3)Now find

Code:
$site_template->register_vars("thumbnails", $thumbnails);
unset($thumbnails);

Add below

Code:


//-----------------------------------------------------
//--- Show Sub Images ---------------------------------
//-----------------------------------------------------

if ($master_cat['cat_master'] == 1){



$sql = "SELECT cat_parent_id
        FROM ".CATEGORIES_TABLE."
      WHERE cat_parent_id = $cat_id";
$total_subs = $site_db->query($sql);
$num_subs = $site_db->get_numrows($total_subs);



$sql = "SELECT i.image_id, i.cat_id, i.image_active, c.cat_parent_id
        FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c
        WHERE i.image_active = 1 AND c.cat_parent_id = $cat_id AND c.cat_id = i.cat_id";

$result2 = $site_db->query($sql);
$num_rows2 = $site_db->get_numrows($result2);


$link_arg = $site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id);

//include(ROOT_PATH.'includes/paging.php');
$getpaging = new Paging($page, $perpage, $num_rows2, $link_arg);
$offset = $getpaging->get_offset();


$site_template->register_vars(array(
  "paging" => $getpaging->get_paging(),
  "paging_stats" => $getpaging->get_paging_stats()
));

$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_parent_id, c.cat_name".get_user_table_field(", u.", "user_name")."
        FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c
        LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
        WHERE i.image_active = 1 AND c.cat_parent_id = $cat_id AND c.cat_id = i.cat_id
        ORDER BY ".$config['image_order']." ".$config['image_sort']."
        LIMIT $offset, $perpage";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);


$imgtable_width = ceil((intval($config['image_table_width'])) / $config['image_cells']);
if ((substr($config['image_table_width'], -1)) == "%") {
  $imgtable_width .= "%";
}

$additional_sql = "";
if (!empty($additional_image_fields)) {
  foreach ($additional_image_fields as $key => $val) {
    $additional_sql .= ", i.".$key;
  }
}

if (!$num_rows)  {
  $thumbnails = "";
  $msg = $lang['no_images'];
}
else {
  $thumbnails = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">\n";
  $count = 0;
  $bgcounter = 0;
  while ($image_row = $site_db->fetch_array($result)){
    if ($count == 0) {
      $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
      $thumbnails .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    $thumbnails .= "<td width=\"".$imgtable_width."\"  =\"top\">\n";

    show_image($image_row);
    $thumbnails .= $site_template->parse_template("thumbnail_bit");
    $thumbnails .= "\n</td>\n";

    $count++;
    if ($count == $config['image_cells']) {
      $thumbnails .= "</tr>\n";
      $count = 0;
    }
  } // end while

  if ($count > 0)  {
    $leftover = ($config['image_cells'] - $count);
    if ($leftover > 0) {
      for ($i = 0; $i < $leftover; $i++){
        $thumbnails .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      $thumbnails .= "</tr>\n";
    }
  }
  $thumbnails .= "</table>\n";
} //end else
$site_template->register_vars("thumbnails", $thumbnails);
unset($thumbnails);
}

Everything red is what I've added. That's it, thanks again for the help!

Greetings
Riser
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: abda53bd on January 28, 2006, 07:38:15 PM
just a note.. for this mod to work.. you need to make a database entry..

under the default

4images_categories

make a new field called
name: cat_master
type: tinyint(4)
collation: none
attributes: none
Null: No
Default 0
Extra: none

i did this mod.. and it still didnt work.. so i used the /admin/categories.php from another site, from before the hack, and plugged it in.. worked fine.. there were some other mods done to it, so i dont know if it will work with yours.. but if you want to try mine out.. feel free. im not going to try to figure out what makes this version work, and the other from this mod/page not work. this is also from 1.7.1
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: cpuswe on March 05, 2006, 12:00:14 PM
Got this to work, but i wish to have "cat_master=yes" by default on all categories, how do i do that?

Edit: Solved it myself.

Just changed "Default" to 1 when added the above.

/Thomas
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: cpuswe on March 05, 2006, 07:32:19 PM
That did not work after all. It does the intended and shows the pictures from respective subcategories in main category. BUT, when you check the single subcategories they apear empty.

The problem is solved by changing cat_master to no in the subcategory.

Idea anyone?

(I made a new post because this topic did not move to the first page when i did the previous post)

/Thomas
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: Tierfotografin on March 20, 2006, 01:40:01 AM
Also ich bekomme es auch nicht zum laufen... Fehlermeldung beim Bearbeiten der Kategorien

 Parse error: parse error, unexpected T_STRING in /meinedomain/4images/admin/categories.php on line 645

Ich find es auch mehr als schade, dass für eigentlich eine so selbstverständliche Sache, man ein Mod braucht.

Könnte mir den jemand einbauen ???

Danke
Doreen
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: Mirwais on April 21, 2006, 07:39:45 PM
Is it possible to let the main catogery to have only 9 latest images instead of haviing all images of sub cat

Hope you guys understand and have a Solution

thansk in advance 
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: Mirwais on May 20, 2006, 06:35:37 PM
Please!!11
reply
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: SNKMAN on July 04, 2006, 12:15:00 AM
Well i've got a little problem with this Mod:

Everything works so far... I can activate the mod at the ACP but i found out, when i insert this code

Code: [Select]
//-----------------------------------------------------
//--- Show Sub Images ---------------------------------
//-----------------------------------------------------

if ($master_cat['cat_master'] == 1){



$sql = "SELECT cat_parent_id
        FROM ".CATEGORIES_TABLE."
      WHERE cat_parent_id = $cat_id";
$total_subs = $site_db->query($sql);
$num_subs = $site_db->get_numrows($total_subs);



$sql = "SELECT i.image_id, i.cat_id, i.image_active, c.cat_parent_id
        FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c
        WHERE i.image_active = 1 AND c.cat_parent_id = $cat_id AND c.cat_id = i.cat_id";

$result2 = $site_db->query($sql);
$num_rows2 = $site_db->get_numrows($result2);


$link_arg = $site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id);

//include(ROOT_PATH.'includes/paging.php');
$getpaging = new Paging($page, $perpage, $num_rows2, $link_arg);
$offset = $getpaging->get_offset();


$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_parent_id, c.cat_name".get_user_table_field(", u.", "user_name")."
        FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c
        LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
        WHERE i.image_active = 1 AND c.cat_parent_id = $cat_id AND c.cat_id = i.cat_id
        ORDER BY ".$config['image_order']." ".$config['image_sort']."
        LIMIT $offset, $perpage";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);


$imgtable_width = ceil((intval($config['image_table_width'])) / $config['image_cells']);
if ((substr($config['image_table_width'], -1)) == "%") {
  $imgtable_width .= "%";
}

$additional_sql = "";
if (!empty($additional_image_fields)) {
  foreach ($additional_image_fields as $key => $val) {
    $additional_sql .= ", i.".$key;
  }
}

if (!$num_rows)  {
  $thumbnails = "";
  $msg = $lang['no_images'];
}
else {
  $thumbnails = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">\n";
  $count = 0;
  $bgcounter = 0;
  while ($image_row = $site_db->fetch_array($result)){
    if ($count == 0) {
      $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
      $thumbnails .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    $thumbnails .= "<td width=\"".$imgtable_width."\"  =\"top\">\n";

    show_image($image_row);
    $thumbnails .= $site_template->parse_template("thumbnail_bit");
    $thumbnails .= "\n</td>\n";

    $count++;
    if ($count == $config['image_cells']) {
      $thumbnails .= "</tr>\n";
      $count = 0;
    }
  } // end while

  if ($count > 0)  {
    $leftover = ($config['image_cells'] - $count);
    if ($leftover > 0) {
      for ($i = 0; $i < $leftover; $i++){
        $thumbnails .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      $thumbnails .= "</tr>\n";
    }
  }
  $thumbnails .= "</table>\n";
} //end else
$site_template->register_vars("thumbnails", $thumbnails);
unset($thumbnails);
}

All my categories are empty....  :cry:

Well i use 4images v. 1.7.2


Someone can help me out??
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: F2F on October 09, 2006, 07:46:38 PM
There is a problem with 1.7.3 version (the one I'm using), where it says:

2.3) find

Code: [Select]
  show_input_row($lang['field_hits'], "cat_hits", $result['cat_hits'], 5);

add after

Code: [Select]
  show_radio_row("cat_master", "cat_master", $result['cat_master']);

It should be:

Quote
2.3) find

Code: [Select]
  show_input_row($lang['field_hits'], "cat_hits", $result['cat_hits'], 5);

add after

Code: [Select]
  show_radio_row($lang['cat_master'], "cat_master", $cat_row['cat_master']);

At least, that's the only way it works for me using $cat_row['cat_master'] instead of $result['cat_master']. Sorry if I'm wrong...

Please, note that I'm also using the lang atribute (or whatever it is called), so you should add it to your language file in case you want to use it too. If not, just remove the lang atribute from the code I posted. Again, sorry if I missed something.

Regards.
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: F4F on October 30, 2006, 07:48:14 PM
Bei mir funktioniert es Perfekt!!!
Allerdings hätte ich noch ein Anliegen:

Wie kann ich auf der Home-Seite auch alle Bilder aller Kategorien anzeigen???


In my case it works perfekt!!!
But I have one extra question:

How can I show all pictures of all categories also on the home site of the gallery???


Nice greetings
F4F
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: knsin0 on June 10, 2007, 11:13:30 PM
I have a problem installing this mod in 1.7.4, when I enable cat_master appear this at the header:

Code: [Select]
DB Error: Bad SQL Query: SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits, c.cat_parent_id, c.cat_name, u.user_name FROM fondosimages i, fondoscategories c LEFT JOIN fondosusers u ON (u.user_id = i.user_id) WHERE i.image_active = 1 AND c.cat_parent_id = 1 AND c.cat_id = i.cat_id ORDER BY image_name ASC LIMIT 0, 9
Unknown column 'i.user_id' in 'on clause'

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\includes\db_mysql.php on line 116

 :|
What im doing wrong?

Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: cristina on June 19, 2007, 01:07:11 AM
I have a problem installing this mod in 1.7.4, when I enable cat_master appear this at the header:

Code: [Select]
DB Error: Bad SQL Query: SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits, c.cat_parent_id, c.cat_name, u.user_name FROM fondosimages i, fondoscategories c LEFT JOIN fondosusers u ON (u.user_id = i.user_id) WHERE i.image_active = 1 AND c.cat_parent_id = 1 AND c.cat_id = i.cat_id ORDER BY image_name ASC LIMIT 0, 9
Unknown column 'i.user_id' in 'on clause'

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\includes\db_mysql.php on line 116

 :|
What im doing wrong?

Had the same problem, but solved it just replacing:

Code: [Select]
        FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c
With this:

Code: [Select]
        FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
Hope this helps!

Regards.
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: knsin0 on June 28, 2007, 09:28:53 PM
I have a problem installing this mod in 1.7.4, when I enable cat_master appear this at the header:

Code: [Select]
DB Error: Bad SQL Query: SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits, c.cat_parent_id, c.cat_name, u.user_name FROM fondosimages i, fondoscategories c LEFT JOIN fondosusers u ON (u.user_id = i.user_id) WHERE i.image_active = 1 AND c.cat_parent_id = 1 AND c.cat_id = i.cat_id ORDER BY image_name ASC LIMIT 0, 9
Unknown column 'i.user_id' in 'on clause'

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\includes\db_mysql.php on line 116

 :|
What im doing wrong?

Had the same problem, but solved it just replacing:

Code: [Select]
        FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c
With this:

Code: [Select]
        FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
Hope this helps!

Regards.

great! now it works perfectly! thanks a lot! i have been a long time trying to fix that  :D
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: knsin0 on July 15, 2007, 04:01:20 AM
Now the mod is only showing the newest pics, i cant see the paging  :?: I see some replies that seems to speak about that, but dont understand german...

edited: problem solved with this http://www.4homepages.de/forum/index.php?topic=10163.msg54840#msg54840 thanks again  :D
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: Lunat on November 04, 2008, 04:40:45 PM
Unfortunately does not work with 4images 1.7.6... Or I am not right?
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: V@no on November 04, 2008, 04:44:47 PM
Any reasons you think it doesn't work? ;)
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: Lunat on November 04, 2008, 05:25:12 PM
Because I tried to put it...

1) Many PhP-commands are changed (for example
Code: [Select]
cat_name "=> htmlspecialchars ($cat_cache [$cat_id] [' cat_name '])). I have corrected them...

2) As a result all the same works nothing. A photo does not show, though numbers of pages are:D
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: V@no on November 04, 2008, 10:47:53 PM
Ok ,in your version it's:
Code: [Select]
  "cat_name" => format_text($cat_cache[$cat_id]['cat_name'], 2),
change it to:
Code: [Select]
  "cat_name2" => format_text($cat_cache[$cat_id]['cat_name'], 2),

Anything else? (sorry, I don't have time to check it myself)
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: Lunat on November 05, 2008, 02:25:41 PM
Yes, I know it. And already corrected by analogy all. But does not work as a result...
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: Lunat on December 17, 2008, 04:40:48 PM
I'm sorry!  :oops: This mod realy work!!!!  :roll:

BUT Some questions:

1) If I has subsubcategories, photos therefrom are not shown. Probably to correct it?
2) Can mod show photos from cat_master too? On a level with subcategories?
3) If I change a category on cat_master, and I come once again into options, is shown that cat_master it is not necessary. Each time to come in phpMyAdmin it is inconvenient
4) Whether it is possible to do cat_master at once at category creation?

If somebody answers at least one question, I will be grateful!  :wink: Thanks
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: littleteam on April 19, 2009, 08:38:09 PM
I tried to install this mod (1.7.6) but I get an error message:

Code: [Select]
DB Error: Bad SQL Query: SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits, c.cat_parent_id, c.cat_name, u.user_name FROM 4images_images i, 4images_categories c LEFT JOIN 4images_users u ON (u.user_id = i.user_id) WHERE i.image_active = 1 AND c.cat_parent_id = 3 AND c.cat_id = i.cat_id ORDER BY image_date DESC LIMIT 0, 12
Unknown column 'i.user_id' in 'on clause'

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/www/web147/html/littleteam/4images/includes/db_mysql.php on line 116

Has someone an idea what I did wrong?
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: V@no on April 19, 2009, 10:27:53 PM
re-do step 3.3
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: littleteam on April 22, 2009, 05:52:29 PM
Hi,

thanks for the reply :). So far so good, the error-message is gone. But now I have the problem, that in the Control Panel I cannot save the settings for cat_master. Each time I click at "yes" and then onto "safe changes" nothing happens. When I check the settings again "no" is still highlighted  :?:
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: khurramalvi on June 16, 2009, 07:54:28 PM
Hi,

I'm getting this error

DB Error: Bad SQL Query: SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, cat_master FROM 4images_categories WHERE cat_parent_id = 0 ORDER BY cat_order, cat_name ASC
Unknown column 'cat_master' in 'field list'
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: Nicky on June 16, 2009, 10:23:34 PM
hi,

you are missing 1st step

Quote
1) First thing to do is create a field in the CATEGORIES_TABLE using a program like PHPMyAdmin. This field should be named cat_master and a type of tinyint(1), not null, and 0 for default.
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: Sebas Bonito on July 14, 2009, 04:14:47 PM
Dont forget, if you upload an image to that category and it has cat_master enabled that image will now show, so you should disable uploading for that category.
Kann das mal wer bitte auf Deutsch erklären. Danke!
Warum sollte das Uploading deaktiviert werden?


Update 1: Eine andere Geschichte. Die MOD läuft soweit, bis auf eine kleine Macke:
Über den "Neuesten Fotos" ist das Paging offenbar falsch:
Code: [Select]
Gefunden: 0 Bild(er) auf 0 Seite(n). Angezeigt: Bild 0 bis 0. Das ist leider nicht richtig. Von mir aus, müssen diese "paging_stats"  
auch nicht über den "Show Sub Images" erscheinen. Jemand ne Idee?

Update 2: So, da fälschlicherweise eine NULL bei mir angezeigt (siehe Update 1),
hab ich mit if und else ein wenig nachgeholfen. Das ist zwar nicht die eleganteste Lösung, aber es funktioniert.  :D
Suche in der categories.php
Code: [Select]
$site_template->register_vars(array(
  "paging" => $getpaging->get_paging(),
  "paging_stats" => $getpaging->get_paging_stats()
));

...und ersetze es mit

Code: [Select]
if ($master_cat['cat_master'] == 1) {
$site_template->register_vars(array(
  "paging" => $getpaging->get_paging()
));
}
else {
$site_template->register_vars(array(
  "paging" => $getpaging->get_paging(),
  "paging_stats" => $getpaging->get_paging_stats()
));
}

...so wird diese Statistikzeile nicht angezeigt, wenn wir diese Vorschaubilder (der neuesten Fotos einer Subkategorie) haben.
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: Sebas Bonito on July 23, 2009, 04:00:17 PM
I've found a bug for 1.7.7

If you've changed the cat_master to 1 (on), save the category and you'll come back to edit something in the category, it says "no" in the cat_master field (even if its "yes" in database).

So search:
Code: [Select]
show_radio_row("cat_master", "cat_master", $result['cat_master']);
and replace it with:
Code: [Select]
show_radio_row("cat_master", "cat_master", $cat_row['cat_master']);
For me it helps!  8)
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: Rinner on August 15, 2009, 10:23:49 AM
Hi! This is a great mod!
I think that this code, added by Riser (http://www.4homepages.de/forum/index.php?topic=10163.msg54840#msg54840) should be added in the first post.
Code: [Select]
$site_template->register_vars(array(
  "paging" => $getpaging->get_paging(),
  "paging_stats" => $getpaging->get_paging_stats()
));
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: Sun Zaza on August 23, 2009, 03:07:57 PM
Hello,

I just discover a bug. After installing this mod, you cannot add any category anymore to you galery.
(Version: 1.7.7)

I got this error message:


Code: [Select]
DB Error: Bad SQL Query: INSERT INTO 4images_categories (cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, cat_password, cat_hide, cat_master) VALUES ('dddd', '', 0, 20, 0, 0, 2, 2, 9, 0, 0, 0, 2, '', 0, )
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 4

Warning: Cannot modify header information - headers already sent by (output started at /hsphere/local/home/*****/******/includes/db_mysql.php:192) in /hsphere/local/home/****/****/includes/functions.php on line 130


Anyone can solve this issue?

Cruxy
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: V@no on August 24, 2009, 03:23:43 AM
in the original instructions no changes being made to the INSERT query...maybe you've changes something else by yourself?
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: Sun Zaza on August 24, 2009, 05:05:29 AM
Thanks V@no for your reply. Actualy I cannot remember that I change something in the code. I don't think so!!!
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: lopsi on October 29, 2009, 07:51:17 PM
Hi,
is it possible, to show all images from subcategories if i have multiple levels of subcategories?

Example:There is a main category, with two subcategories, each with (sub)subcategories.
All images form the (sub)subcategories should be shown in the above subcategory, all images from the subcategories in the main category.

In the actual mod this only works for 1 level.

Or is there another solution/mod for this (I couldnt find one here)? It´s not necessary to have the possibility to select if a categroy is cat_master or not - i just wan´t to put images in only one category

Thanks for ypur help!
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: StanleyJoey on April 24, 2010, 12:40:29 PM
Everything works perfect after reading all posts , thanks!
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: DPHAZE on October 25, 2010, 12:16:16 AM
Hello there,

just a short question related to this great mod.
is there any solution to limit the number of the shown images (1 or 2 images) from each sub-cat? ( i.e. show only the latest image from a sub-cat)

if so, that would be a great possibility to show a "preview-like-image" as a reference for each sub-cat content.

thanks in advance and cheers
Title: Re: [MOD COMPLETE] Show newest images in main cat from sub cat. + paging!
Post by: jacobmathias on March 10, 2011, 08:33:55 PM
this mod works great, followed the replies and got some extra fixes, like the paging. Follow the instructions and you can set this up in less than 10 minutes.