4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: Fugaziman on April 07, 2003, 04:39:23 AM

Title: [Mod] Create Sort Order for each category from Admin Panel
Post by: Fugaziman on April 07, 2003, 04:39:23 AM
This Mod will allow each category to have it's own Sort Order.

I created this so that some of my categories can be displayed in sequence using the image name but others I just want to display with the latest first ie. using date_order.

Two things to note:
1) It stops the default Sort order set using the Admin Panel - Settings Page.
2) The Mod in this forum for allowing users to select their own sort order will not work on the Categories page. However it will still work in the Search and New Images pages (same page really)

The Mod it quite easy to install but make sure you backup/make copy of your files first. Just in case  :D

Step 1.  :arrow:  Add 2 new fields to your categories table
sort_order  varchar(5)   Default "ASC"
sort_field    varchar(20) Default "image_name"

Thanks to V@no (Helps us unfortunate newbies all the time  :D )
Heres the link for the DB installer..
Category Sort Install (http://gallery.vano.org/file8dl)
Just download the zip file, unzip it to your root directory and call it from your browser.
 
Step 2.  :arrow:  Backup ./global.php
   Edit ./global.php

4images v1.7
Search for ...
Code: [Select]
 $sql = "SELECT c.cat_id, c.cat_name, c.cat_description, c.cat_parent_id, c.cat_hits, c.cat_order, c.auth_viewcat, c.auth_viewimage, c.auth_download, c.auth_upload, c.auth_directupload, c.auth_vote, c.auth_sendpostcard, c.auth_readcomment, c.auth_postcomment, COUNT(i.image_id) AS new_images
          FROM ".CATEGORIES_TABLE." c
          LEFT JOIN ".IMAGES_TABLE." i ON (i.cat_id = c.cat_id AND i.image_date >= $new_cutoff AND i.image_active = 1)
          GROUP BY c.cat_id
          ORDER BY c.cat_order, c.cat_name ASC";

Replace with ...

Code: [Select]
 $sql = "SELECT c.cat_id, c.cat_name, c.cat_description, c.cat_parent_id, c.cat_hits, c.cat_order, c.auth_viewcat, c.auth_viewimage, c.auth_download, c.auth_upload, c.auth_directupload, c.auth_vote, c.auth_sendpostcard, c.auth_readcomment, c.auth_postcomment, c.sort_order, c.sort_field, COUNT(i.image_id) AS new_images
          FROM ".CATEGORIES_TABLE." c
          LEFT JOIN ".IMAGES_TABLE." i ON (i.cat_id = c.cat_id AND i.image_date >= $new_cutoff AND i.image_active = 1)
          GROUP BY c.cat_id
          ORDER BY c.cat_order, c.cat_name ASC";

4images v1.7.1

Search for ...
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, sort_order, sort_field

Step 3.  :arrow:  Backup ./categories.php
   Edit ./categories.php
Search for sql line containing ...
Code: [Select]
ORDER BY
Replace Whole Line with...
Code: [Select]
       ORDER BY ".$cat_cache[$cat_id]['sort_field']." ".$cat_cache[$cat_id]['sort_order']."
Step 4.  :arrow:  Backup ./lang/yourlang/admin.php
   Edit ./lang/yourlang/admin.php
Insert just ABOVE
Code: [Select]
?> at end of page

Code: [Select]
//--------------Images Sort-------------------------
//---Used by Category Sort Option Mod            ---
//--------------------------------------------------
$lang['image_order'] = "Sort images by";
$image_order_optionlist = array(
  "image_name"      => "Name",
  "image_date"      => "Date",
  "image_downloads" => "Downloads",
  "image_votes"     => "Votes",
  "image_rating"    => "Rating",
  "image_hits"      => "Hits"
);
$lang['image_sort'] = "Ascending/Descending";
$image_sort_optionlist = array(
  "ASC"  => "Ascending",
  "DESC" => "Descending"
);
//--------------------------------------------------
//---End of Category Sort Option Mod             ---
//--------------------------------------------------

Step 5.  :arrow: Backup ./admin/categories.php
   Edit ./admin/categories.php

Search for ...
Code: [Select]
if ($action == "savecat") {
  $error = array();
  $cat_name = un_htmlspecialchars(trim($HTTP_POST_VARS['cat_name']));
  $cat_description = un_htmlspecialchars(trim($HTTP_POST_VARS['cat_description']));
  $cat_parent_id = intval($HTTP_POST_VARS['cat_parent_id']);
  $cat_order = (isset($HTTP_POST_VARS['cat_order'])) ? intval($HTTP_POST_VARS['cat_order']) : 0;
 
Immediatley After INSERT these 2 lines...
Code: [Select]
 $sort_order = trim($HTTP_POST_VARS['imagesradio']);
  $sort_field = trim($HTTP_POST_VARS['imagesorder']);

Search for ...
Code: [Select]
   $sql = "INSERT INTO ".CATEGORIES_TABLE."
            (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)
            VALUES
            ('$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)";

Replace with ...
Code: [Select]
   $sql = "INSERT INTO ".CATEGORIES_TABLE."
            (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, sort_order, sort_field)
            VALUES
            ('$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, '$sort_order', '$sort_field')";

Search for ...
Code: [Select]
 show_textarea_row($lang['field_description_ext'], "cat_description", "", $textarea_size);  
Immediatley After, INSERT this...
Code: [Select]
 $imgsort_dropdown="\n<select name=\"imagesorder\" class=\"setperpageselect\">\n";
  foreach ($image_order_optionlist as $key => $val) {
    $imgsort_dropdown .= "<option value=\"$key\"";
    if ($config['image_order'] == $key) {
      $imgsort_dropdown .= " selected=\"selected\"";
    }
    $imgsort_dropdown .= ">".$val."</option>\n";
  }
  $imgsort_dropdown .= "</select>\n";
  
  foreach ($image_sort_optionlist as $key => $val) {
  $imgsort_radio .= "<INPUT type=\"radio\" name=\"imagesradio\" value=\"$key\"";
  if ($config['image_sort'] == $key) {
      $imgsort_radio .= " checked";
  }
  $imgsort_radio .= ">".$val."\n";
  }
  show_custom_row($lang['image_order'], $imgsort_dropdown);
  show_custom_row($lang['image_sort'], $imgsort_radio);

Search for ...
Code: [Select]
if ($action == "savecat") {
  $error = array();
  $cat_name = un_htmlspecialchars(trim($HTTP_POST_VARS['cat_name']));
  $cat_description = un_htmlspecialchars(trim($HTTP_POST_VARS['cat_description']));
  $cat_parent_id = intval($HTTP_POST_VARS['cat_parent_id']);
  $cat_order = (isset($HTTP_POST_VARS['cat_order'])) ? intval($HTTP_POST_VARS['cat_order']) : 0;

Immediatley After, INSERT this...
Code: [Select]
 $sort_order = trim($HTTP_POST_VARS['imagesradio']);
  $sort_field = trim($HTTP_POST_VARS['imagesorder']);

Search for ...
Code: [Select]
if ($action == "updatecat") {
  $error = array();
  $cat_id = (isset($HTTP_POST_VARS['cat_id'])) ? intval($HTTP_POST_VARS['cat_id']) : intval($HTTP_GET_VARS['cat_id']);
  $cat_parent_id = intval($HTTP_POST_VARS['cat_parent_id']);
  $cat_name = un_htmlspecialchars(trim($HTTP_POST_VARS['cat_name']));
  $cat_description = un_htmlspecialchars(trim($HTTP_POST_VARS['cat_description']));
  $cat_hits = intval(trim($HTTP_POST_VARS['cat_hits']));
  $cat_order = (isset($HTTP_POST_VARS['cat_order'])) ? intval($HTTP_POST_VARS['cat_order']) : 0;
 
Immediatley After, INSERT this...
Code: [Select]
 $sort_order = trim($HTTP_POST_VARS['imagesradio']);
  $sort_field = trim($HTTP_POST_VARS['imagesorder']);
 
Search for ...
Code: [Select]
   $sql = "UPDATE ".CATEGORIES_TABLE."
            SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_order = $cat_order, 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
            WHERE cat_id = $cat_id";
           
Replace with ...
Code: [Select]
   $sql = "UPDATE ".CATEGORIES_TABLE."
            SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_order = $cat_order, 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, sort_order = '$sort_order', sort_field = '$sort_field'
            WHERE cat_id = $cat_id";
           
Search for ...
Code: [Select]
 $sql = "SELECT cat_name, cat_description, cat_parent_id, cat_order, cat_hits, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
          FROM ".CATEGORIES_TABLE."
          WHERE cat_id = $cat_id";
         
Replace with ...
Code: [Select]
 $sql = "SELECT cat_name, cat_description, cat_parent_id, cat_order, cat_hits, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, sort_order, sort_field
          FROM ".CATEGORIES_TABLE."
          WHERE cat_id = $cat_id";
         
Search for ...
Code: [Select]
 show_textarea_row($lang['field_description_ext'], "cat_description", $cat_row['cat_description'], $textarea_size);
Immediatley After INSERT this ...
Code: [Select]
 $imgsort_dropdown="\n<select name=\"imagesorder\" class=\"setperpageselect\">\n";
  foreach ($image_order_optionlist as $key => $val) {
    $imgsort_dropdown .= "<option value=\"$key\"";
    if ($cat_row['sort_field'] == $key) {
      $imgsort_dropdown .= " selected=\"selected\"";
    }
    $imgsort_dropdown .= ">".$val."</option>\n";
  }
  $imgsort_dropdown .= "</select>\n";
  
  foreach ($image_sort_optionlist as $key => $val) {
  $imgsort_radio .= "<INPUT type=\"radio\" name=\"imagesradio\" value=\"$key\"";
  if ($cat_row['sort_order'] == $key) {
      $imgsort_radio .= " checked";
  }
  $imgsort_radio .= ">".$val."\n";
  }
  show_custom_row($lang['image_order'], $imgsort_dropdown);
  show_custom_row($lang['image_sort'], $imgsort_radio);
 
Search for ...
Code: [Select]
if ($action == "modifycats") {
  if ($msg != "") {
    printf("<b>%s</b>\n<p>", $msg);
  }
  $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
          FROM ".CATEGORIES_TABLE."
          ORDER BY cat_order, cat_name ASC";
  $result = $site_db->query($sql);

Replace with ....
Code: [Select]
if ($action == "modifycats") {
  if ($msg != "") {
    printf("<b>%s</b>\n<p>", $msg);
  }
  $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, sort_order, sort_field
          FROM ".CATEGORIES_TABLE."
          ORDER BY cat_order, cat_name ASC";
  $result = $site_db->query($sql);

THAT'S IT PEOPLE.
Now just go into your Admin Panel - Edit Categories and set your sort orders. If you created the 2 extra table fields above the default sort order for all existing categories will be image_name ASC.

Good luck  8)
Fugaziman
Title: [Mod] Create Sort Order for each category from Admin Panel
Post by: toto1 on May 08, 2003, 02:31:33 PM
excellent thk :D  :D
Title: [Mod] Create Sort Order for each category from Admin Panel
Post by: lakeside on May 11, 2003, 12:00:46 AM
Have a problem
When I run install_cat_sort.php I get the following error:
Code: [Select]
DB Error: Bad SQL Query: ALTER TABLE 4imagesg_categories ADD `sort_order` VARCHAR( 5 ) DEFAULT 'ASC' NOT NULL , ADD `sort_field` VARCHAR( 20 ) DEFAULT 'image_name' NOT NULL ;
You have an error in your SQL syntax near '; ' at line 1


What has caused this please?
Title: [Mod] Create Sort Order for each category from Admin Panel
Post by: V@no on May 11, 2003, 12:43:09 AM
Quote from: lakeside
Have a problem
When I run install_cat_sort.php

try to delete semicolon:
Quote
NOT NULL ;
Title: [Mod] Create Sort Order for each category from Admin Panel
Post by: helluvaguy on May 11, 2003, 11:14:54 AM
This is a really fine mod, thx.

I was just wondering, if this one "bug" is happening only to my or if others experience the same thing.

When I'm changing the sortorder for a category in the ACP, this categorie "jumps" to the 1st place on this level, eventhough it was last in the list before.

Can anyone tell me something about that.
Title: [Mod] Create Sort Order for each category from Admin Panel
Post by: helluvaguy on May 11, 2003, 01:51:47 PM
By the way is ths mod compatible with v@nos [Mod] Let visitors to chose how to sort images(date,name,..) ?
Title: [Mod] Create Sort Order for each category from Admin Panel
Post by: V@no on May 11, 2003, 02:49:55 PM
yes, its working in a different way ;)
Title: [Mod] Create Sort Order for each category from Admin Panel
Post by: helluvaguy on May 11, 2003, 06:27:46 PM
Quote from: V@no
yes, its working in a different way ;)

Meaning :?:
Title: [Mod] Create Sort Order for each category from Admin Panel
Post by: V@no on May 11, 2003, 07:09:53 PM
meaning "just dont worry" hehe :lol: ;)
sereously those two mods are do compleately different things, and can not affect each other.
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: jarano on May 04, 2005, 05:19:37 PM
Hola!!
Se me cayó el cielo! No puedo entrar al Panel de Control y mi web está llena de mensajes de errores....como este:

Warning: mysql_fetch_array(): 7 is not a valid MySQL result resource in /home/celeper/public_html/galeria/includes/db_mysql.php on line 92

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/celeper/public_html/galeria/includes/db_mysql.php:92) in /home/celeper/public_html/galeria/includes/sessions.php on line 84

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/celeper/public_html/galeria/includes/db_mysql.php:92) in /home/celeper/public_html/galeria/includes/sessions.php on line 84

Warning: Cannot modify header information - headers already sent by (output started at /home/celeper/public_html/galeria/includes/db_mysql.php:92) in /home/celeper/public_html/galeria/includes/sessions.php on line 92

Warning: Cannot modify header information - headers already sent by (output started at /home/celeper/public_html/galeria/includes/db_mysql.php:92) in /home/celeper/public_html/galeria/includes/sessions.php on line 92

Warning: Cannot modify header information - headers already sent by (output started at /home/celeper/public_html/galeria/includes/db_mysql.php:92) in /home/celeper/public_html/galeria/includes/sessions.php on line 92

no puedo desinstalar el install_cat_xx que puse en la base de datos. Como puedo desinstalarlo o que debo corregir? Please...mi web es una desgracia...mirenla...http://www.celebridadesperuanas.com/galeria
Help...glu...glu...glugggg.....
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: Josef Florian on May 18, 2005, 09:00:10 AM
When i try STEP 1 to search for

Code: [Select]
...c.cat_id, c.cat_name, c.cat_description, c.cat_parent_id, c.cat_hits...
i can't find this string!


Since a few days, i know that in version 1.7.1 is a modification of this c.cat_id

What should i do, to install that mod on version 1.7.1?

LieGrü
Josef Florian
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: Sopur on May 25, 2005, 05:01:23 PM
Hello!
I can't find the database installer. Can I do the mod anyway?
Regards
Sopur
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: tobiasth on June 20, 2005, 10:18:33 PM
What should i do, to install that mod on version 1.7.1?

are there any solutions? would be great if this is working with v1.7.1! plz, we need your help :wink:

thx!
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: marod0er on June 24, 2005, 08:46:11 PM
Great MOD, thanks!
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: tobiasth on June 27, 2005, 11:39:50 PM
hey guys!

this is not working with v1.7.1, can anyone fix it ? many thx!

cya,
tobi
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: Sopur on June 28, 2005, 12:39:26 PM
Where can I download the install file? Or could someone mail it to me?
Regards
Sopur
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: Tiburon on June 28, 2005, 02:15:14 PM
You should find it here:

http://gallery.vano.org/en/file8dl   :)

Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: Sopur on June 28, 2005, 03:18:18 PM
Yes, I know, but I can't see anythink on that page :-(
Could you mail it to me?
Regards
Sopur
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: PaulB on July 07, 2005, 03:59:46 PM
Maybe you are using a new version of IE that blocks such things. Look if there's a line under the address bar saying 'download blocked'. If so, click on it and allow download.
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: tobiasth on July 18, 2005, 07:37:39 PM
this is not working with v1.7.1, can anyone fix it ? many thx!
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: henary on August 01, 2005, 07:11:12 PM
Hi,

i've set up this MOD with 1.7.1 - it isn't easy, but i've make a short HOWTO for others. Please contact me here or with PM if you like to get this. In this time, i havn't tested this on other 4images installs, because i've a lot of other MODs and self-made MODs.

Your choice,
Henry
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: V@no on August 02, 2005, 12:02:04 AM
Hi,

i've set up this MOD with 1.7.1 - it isn't easy, but i've make a short HOWTO for others. Please contact me here or with PM if you like to get this. In this time, i havn't tested this on other 4images installs, because i've a lot of other MODs and self-made MODs.

Your choice,
Henry

are you sure that you would reather reply to many people many times with same code, other then post it ones here and nobody would bother u with pms/emails?
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: henary on August 11, 2005, 11:07:57 PM
Hi V@no,

you are right, i will make this how-to for publishing here. I didn't post the easy current how-to, because i'm afraid you will cancel this like my other post last time. I don't know, why you killed the last. But it's done ;-)

@ all:
Please wait some days.

Regards,
Henry
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: V@no on August 12, 2005, 01:12:19 AM
because i'm afraid you will cancel this like my other post last time. I don't know, why you killed the last.
what? :?
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: henary on August 14, 2005, 12:31:37 PM
Hi V@no,
OH, i'm stupid!
I'm wrong with the names, sorry!

A topic you are watching has been locked by Vincent.
View the topic at: http://www.4homepages.de/forum/index.php?topic=7546.new;topicseen#new
A topic you are watching has been removed by Vincent.


May Vincent will answer me?

I'm sorry again V@no,
Henry
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: Vincent on August 14, 2005, 11:37:06 PM
Hello
first sorry if i have removed something!  :oops:
 but
what should i have removed
why should i remove
and i am allow to remove something?  :wink:

sincerly
vincent
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: tobiasth on August 14, 2005, 11:55:59 PM
what about the main subject here on this thread ?
plz, anyone, help us fixing this mod to use with v1.7.1 !!! any serious help ?
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: V@no on August 15, 2005, 03:40:41 AM
what about the main subject here on this thread ?
plz, anyone, help us fixing this mod to use with v1.7.1 !!! any serious help ?
ok, I've added support for v1.7.1 in Step 2

P.S. next time please be more specific what exactly is not working.
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: tobiasth on August 15, 2005, 11:52:25 AM
hi! thx for your help, but i have the following error:

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_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 i.cat_id = 21 AND c.cat_id = i.cat_id ORDER BY ASC LIMIT 0, 40
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 'ASC LIMIT 0, 40' at line 5

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /www/htdocs/v028833/gallery/includes/db_mysql.php on line 116

any help?

you can see it i.e. here: http://www.tobiasth.de/gallery/categories.php?cat_id=36
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: V@no on August 15, 2005, 02:14:28 PM
ops, my bad, missed one field. redo step 2
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: tobiasth on August 15, 2005, 02:36:56 PM
many thx, its working great now!

but, i want one more thing, i think its not very difficult.

(http://www.tobiasth.de/tmp/error.jpg)

at the top of the image you see how it is now when i click the categorie in the admin panel.
at the buttom you can see what i want. its not showing what kind of sort is now set up :(

you see a change to fix this too ? :)

many many thx for your help!
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: V@no on August 15, 2005, 03:08:45 PM
it should do that by default...I see no error in the published code (note, I havent tested it yet)
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: henary on August 15, 2005, 11:19:03 PM
Hi,

i had fixed this last time. It is dificult to find, but please try this. I havn't tested my result on other 4images installs...

open /admin/categories.php

You will find twice
Code: [Select]
$imgsort_dropdown="\n<select name=\"imagesorder\" class=\"setperpageselect\">\n";First some behind
Code: [Select]
if ($action == "addcat") {there are two lines
Code: [Select]
if ($cat_row['sort_field'] == $key) {and
Code: [Select]
if ($cat_row['sort_order'] == $key) {Those are ok.
Second result of
Code: [Select]
$imgsort_dropdown="\n<select name=\"imagesorder\" class=\"setperpageselect\">\n";some behind
Code: [Select]
if ($action == "editcat") {There is the same like
Code: [Select]
if ($cat_row['sort_field'] == $key) {and
Code: [Select]
if ($cat_row['sort_order'] == $key) {but here you have to replace with this:
Code: [Select]
if ($result['sort_field'] == $key) {and
Code: [Select]
if ($result['sort_order'] == $key) {That's may be all at, please try and report.
Henry
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: henary on August 16, 2005, 07:59:50 AM
Hi again,

if you like some more information in categorie-list like this:
(http://home.arcor.de/henary/cat_list.gif)

To change: /admin/categories.php ** Please make backup before yo start! **

search:
Code: [Select]
function show_category_rows($cid = 0, $depth = 1) {
  global $site_db, $site_sess, $lang, $category_cache;

  if (!isset($category_cache[$cid])) {
    return false;
  }
  foreach ($category_cache[$cid] as $key => $cats) {
    $class = "tablerow2";
    if ($cats['cat_parent_id'] == 0) {
      $class = "tablerow";
    }

Add after:
Code: [Select]
  $sql = "SELECT COUNT(cat_id) AS images
FROM ".IMAGES_TABLE."
WHERE cat_id = ".$cats['cat_id'];

  $result = $site_db->query_firstrow($sql);
  $sum = $result['images'];

  $sql = "SELECT cat_id, sort_order, sort_field
        FROM ".CATEGORIES_TABLE."
WHERE cat_id = ".$cats['cat_id'];
  $result = $site_db->query_firstrow($sql);
 
  global $image_sort_optionlist;
  $sortorder = "unset";
  foreach ($image_sort_optionlist as $key => $val) {
    if ($result['sort_order'] == $key) {
$sortorder = $val;
    }
  }
  global $image_order_optionlist;
  $sortfield = "unset";
  foreach ($image_order_optionlist as $key => $val) {
    if ($result['sort_field'] == $key) {
$sortfield = $val;
    }
  }

Search:
Code: [Select]
    echo "<img src=\"".ROOT_PATH."admin/images/folder.gif\" alt=\"\"><b><a href=\"".$site_sess->url(ROOT_PATH."categories.php?cat_id=".$cats['cat_id'])."\" target=\"_blank\">".$cats['cat_name']."</a>\n</b> (ID: ".$cats['cat_id'].")&nbsp;&nbsp;&nbsp;&nbsp;";
Replace with:
Code: [Select]
    echo "<img src=\"".ROOT_PATH."admin/images/folder.gif\" alt=\"\"><b><a href=\"".$site_sess->url(ROOT_PATH."categories.php?cat_id=".$cats['cat_id'])."\" target=\"_blank\">".$cats['cat_name']."</a>\n</b> (ID: ".$cats['cat_id'].")&nbsp;&nbsp;(Bilder: ".$sum.")&nbsp;&nbsp;(".$sortfield.", ".$sortorder.") &nbsp;&nbsp;&nbsp;&nbsp;";
"unset" will shown, if you didn't set any sort by the new MOD from this thread.

Thats all, please try and report, if something fails.

Regards,
Henry
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: henary on August 16, 2005, 08:16:11 AM
Hello
first sorry if i have removed something!  :oops:
 but
what should i have removed
why should i remove
and i am allow to remove something?  :wink:

sincerly
vincent

Hi vincent,

please go to http://www.4homepages.de/forum/index.php?topic=9324.new#new, because we shouldn't discuss this here ;-)
Henry
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: Luci on August 27, 2005, 02:30:58 PM
erst mal ein großes lob für den hack. genau sowas hab ich gebraucht. nur hab ich das problem dass bei mir die sortierung (Ascending, Descending) nicht angezeigt wird und ich finde den fehler nicht. kann jemand helfen?
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: henary on October 02, 2005, 07:42:59 PM
Hi Luci,

sorry, war etwas im Urlaub - ist die Frage noch aktuell? Hatte das Prob auch - liegt an einem Fehler im Original-Mod...

Grüße,
Henry
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: TIMT on October 24, 2005, 01:56:10 PM
do I have to make the modification in step 3 for  5 times? for each line containing "ORDER BY"?
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: Sopur on November 14, 2005, 05:37:33 PM
Hello!
I wanted to install this mod (I hope, I aded the two lines the correct way to the database, because I wasn't able to download the instal file).
But after I did all the changes, I had some lines above the pictures, and the control panel was no more reachable, It was written:
DB Error: Bad SQL Query: SELECT c.cat_id, c.cat_name, c.cat_description, c.cat_parent_id, c.cat_hits, c.cat_order, c.auth_viewcat, c.auth_viewimage, c.auth_download, c.auth_upload, c.auth_directupload, c.auth_vote, c.auth_sendpostcard, c.auth_readcomment, c.auth_postcomment, c.sort_order, c.sort_field, COUNT(i.image_id) AS new_images FROM 4images_categories c LEFT JOIN 4images_images i ON (i.cat_id = c.cat_id AND i.image_date >= 1131121813 AND i.image_active = 1) GROUP BY c.cat_id ORDER BY c.cat_order, c.cat_name ASC
Unknown column 'c.sort_order' in 'field list'
What did I wrong? By modding the last file (Nr. 5), I had the problem, some strings didn't match exactly! Why could this be?
I'm running V 1.7.
Would be really happy, if I could get this to work  :cry:

Regards
Sopur
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: V@no on November 15, 2005, 12:32:17 AM
You did not update database properly.
Run this query in your favorite mysql manager:
Code: [Select]
ALTER TABLE 4images_categories ADD `sort_order` VARCHAR( 5 ) DEFAULT 'ASC' NOT NULL , ADD `sort_field` VARCHAR( 20 ) DEFAULT 'image_name' NOT NULL ;
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: Sopur on November 15, 2005, 10:22:31 AM
Hello!
Thanks for your reply! Unfortunately, it didn't work :-(
When I go to the page, it says above the categories (and they are no more there!):

DB Error: Bad SQL Query: SELECT c.cat_id, c.cat_name, c.cat_description, c.cat_parent_id, c.cat_hits, c.cat_order, c.auth_viewcat, c.auth_viewimage, c.auth_download, c.auth_upload, c.auth_directupload, c.auth_vote, c.auth_sendpostcard, c.auth_readcomment, c.auth_postcomment, c.sort_order, c.sort_field, COUNT(i.image_id) AS new_images FROM 4images_categories c LEFT JOIN 4images_images i ON (i.cat_id = c.cat_id AND i.image_date >= 1131181784 AND i.image_active = 1) GROUP BY c.cat_id ORDER BY c.cat_order, c.cat_name ASC
Unknown column 'c.sort_order' in 'field list'

and when I want to go to the control panel it's only this sentence there.

As mentioned in the upper post, I have some problems to find the strings in the /admin/categories.php file.
I now wrote my missing parts:

Missing of the line:
$cat_order = (isset($HTTP_POST_VARS['cat_order'])) ? intval($HTTP_POST_VARS['cat_order']) : 0;
(would be line 513)

Miising of
cat_order,
in line 556

Missing of
$cat_row['cat_description']
in line 456

I know, the lines aren't a really good thing to say where, because they must not be the same at an other editor.

Why are those things missing at mine?
I would like to send the file, if anyone could help. Or could anyone send the correct file to me? (would that work?)
Many thanks
Sopur

Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: Acidgod on November 15, 2005, 11:35:18 AM
you can send me a account for your favorite mysql manager & admin account for 4images by PN and i will take a look where is the Problem... (o:
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: Sopur on November 15, 2005, 02:58:17 PM
Many thanks for your offer! Man, I was dump: under the shower I had the idea: perhaps I took the wrong database...  :oops:
So it think, it should work now.
I still have some problems:
My screen the create a new categorie looks like this:
(http://www.schwab.ch/pages/bilder/foren/4images.gif)
And I didn't find a way to change the existing categories. Do I have to ad something more?
Regards
Sopur
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: Acidgod on November 15, 2005, 04:28:10 PM
Kategorie bearbeiten?  :D
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: Sopur on November 15, 2005, 04:36:27 PM
Leider nicht :-(
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: Sopur on November 19, 2005, 09:22:22 PM
Ich hab's jetzt so einigermassen geschafft, ich denke, es funktioniert.
Was ich aber jetzt für ein Problem habe: jedes mal, wenn ich irgendeine Kategorie bearbeite oder erstelle bringt es mir die Reihenfolge der Kategorien durcheinander. Was kann man dagegen tun?
Vielen Dank für Eure Hilfe!
M
F
G
Sopur
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: fatro on July 15, 2006, 03:41:22 PM
hello guys!

I already install this mod, It's worked fine but I found some problem.
It's only sort the thumbnails! when I navigate with "Previous" or "Next" button,
It's still using the default Sort order set at the Admin Panel - Settings Page

What should I do to fix that up??

thanx in advance
fatro
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: V@no on July 15, 2006, 07:08:03 PM
Not tested.
in details.php find:
Code: [Select]
          ORDER BY ".$config['image_order']." ".$config['image_sort'].", image_id ASC";
Replace with:
Code: [Select]
          ORDER BY ".$cat_cache[$image_row['cat_id']]['sort_field']." ".$cat_cache[$image_row['cat_id']]['sort_order']." , image_id ASC";
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: fatro on July 15, 2006, 10:31:31 PM
Thank alot V@no..

There are about 3 lines of
[qcode]ORDER BY ".$config['image_order']." ".$config['image_sort'];[/qcode]
with no
[qcode].", image_id ASC"[/qcode]
behind

so, I replace your code to all 3. It's give me
Quote
DB Error: Bad SQL Query: SELECT image_id, cat_id, image_name, image_media_file, image_thumb_file FROM 4images_images WHERE image_active = 1 AND cat_id = 1 ORDER BY DESC , image_id ASC
You have an error in your SQL syntax near 'DESC , image_id ASC' at line 4

Above the "details.php" page (I use v.1.7.1)

Do you have any idea what is wrong?.. again, thank in advance :roll:
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: V@no on July 15, 2006, 11:02:47 PM
I use v.1.7.1
That why we are trying to encourage people add 4images version they are using into their profile signature, so we dont have to waste our time either ask for it or answer for a wrong version.

the line you should look for is below
Code: [Select]
if (!$in_mode || empty($sql)) {

Replace it with:
Code: [Select]
         ORDER BY ".$cat_cache[$image_row['cat_id']]['sort_field']." ".$cat_cache[$image_row['cat_id']]['sort_order'];
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: fatro on July 15, 2006, 11:54:55 PM
Thank a Lot V@no  :mrgreen:

That why we are trying to encourage people add 4images version they are using into their profile signature, so we dont have to waste our time either ask for it or answer for a wrong version.
I'm newbie here, sorry for that  :oops:

I'm looking forward to change to 1.7.2 but I think with many plugins I have. It'll be very messy :?
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: cronk005 on September 04, 2006, 01:53:59 AM
Hi There==

I did all instructions as indicated in the original post, however, I get the following error.

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_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 i.cat_id = 18 AND c.cat_id = i.cat_id ORDER BY image_name ASC image_date DESC LIMIT 20, 20
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 'image_date DESC LIMIT 20, 20' at line 5

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/traveli/public_html/galleries/includes/db_mysql.php on line 116


I am using 1.7.2

Any thoughts--

DEC
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: V@no on September 04, 2006, 03:57:09 AM
Step 3 sais to replace the whole line, but you seems to added something else...
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: cronk005 on September 04, 2006, 05:16:08 AM
OK. I figured that out. My mistake. Now.... perhaps another mistake. The category will sort correct (based on the new parameters that I set), however, once I click on the first image for example, it then will show you next and previous image links based on the date, which is the system default. Did I miss something that I should have changed?

DECronk
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: V@no on September 04, 2006, 05:35:23 AM
I guess this mod is not full...
in details.php find:
Code: [Select]
            AND cat_id IN ($cat_id_sql)
            ORDER BY ".$config['image_order']." ".$config['image_sort'].", image_id ".$config['image_sort'];
Replace with:
Code: [Select]
            AND cat_id IN ($cat_id_sql)
            ORDER BY ".$cat_cache[$cat_id]['sort_field']." ".$cat_cache[$cat_id]['sort_order'].", image_id ".$cat_cache[$cat_id]['sort_order'];
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: cronk005 on September 04, 2006, 06:13:59 AM
Thanks v@no... I changed that one and it at first did not work. But then there is another line right below it which is similar that I changed to read something just like the above and it worked perfectly.. thanks for leading me in the right direction.

dec
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: V@no on September 04, 2006, 02:11:18 PM
there only one instance of these lines, so you shouldnt look for simular, but for exact match ;)
Title: Re: [Mod] Create Sort Order for each category from Admin Panel
Post by: Sunny C. on November 28, 2011, 02:17:05 PM
Works with 4images 1.7.10

Addons:
- More informations (http://www.4homepages.de/forum/index.php?topic=5026.msg44175#msg44175)

Install SQL:
- DB Install (http://www.4homepages.de/forum/index.php?topic=5026.msg51855#msg51855)