Author Topic: [Mod] Create Sort Order for each category from Admin Panel  (Read 81321 times)

0 Members and 1 Guest are viewing this topic.

Offline tobiasth

  • Pre-Newbie
  • Posts: 7
    • View Profile
Re: [Mod] Create Sort Order for each category from Admin Panel
« Reply #30 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.



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!

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [Mod] Create Sort Order for each category from Admin Panel
« Reply #31 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)
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 henary

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: [Mod] Create Sort Order for each category from Admin Panel
« Reply #32 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

Offline henary

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: [Mod] Create Sort Order for each category from Admin Panel
« Reply #33 on: August 16, 2005, 07:59:50 AM »
Hi again,

if you like some more information in categorie-list like this:


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

Offline henary

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: [Mod] Create Sort Order for each category from Admin Panel
« Reply #34 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

Offline Luci

  • Pre-Newbie
  • Posts: 1
    • View Profile
Re: [Mod] Create Sort Order for each category from Admin Panel
« Reply #35 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?

Offline henary

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: [Mod] Create Sort Order for each category from Admin Panel
« Reply #36 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

Offline TIMT

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
Re: [Mod] Create Sort Order for each category from Admin Panel
« Reply #37 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"?

Offline Sopur

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
    • Bilder des Harassenlaufs in Basel
Re: [Mod] Create Sort Order for each category from Admin Panel
« Reply #38 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

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [Mod] Create Sort Order for each category from Admin Panel
« Reply #39 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 ;
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 Sopur

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
    • Bilder des Harassenlaufs in Basel
Re: [Mod] Create Sort Order for each category from Admin Panel
« Reply #40 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


Offline Acidgod

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 2.420
  • It's me?
    • View Profile
    • Flash-Webdesign
Re: [Mod] Create Sort Order for each category from Admin Panel
« Reply #41 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:

Offline Sopur

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
    • Bilder des Harassenlaufs in Basel
Re: [Mod] Create Sort Order for each category from Admin Panel
« Reply #42 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:

And I didn't find a way to change the existing categories. Do I have to ad something more?
Regards
Sopur

Offline Acidgod

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 2.420
  • It's me?
    • View Profile
    • Flash-Webdesign
Re: [Mod] Create Sort Order for each category from Admin Panel
« Reply #43 on: November 15, 2005, 04:28:10 PM »
Kategorie bearbeiten:D

Offline Sopur

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
    • Bilder des Harassenlaufs in Basel
Re: [Mod] Create Sort Order for each category from Admin Panel
« Reply #44 on: November 15, 2005, 04:36:27 PM »
Leider nicht :-(