Author Topic: Exclude categories from random  (Read 9530 times)

0 Members and 1 Guest are viewing this topic.

skiemor

  • Guest
Exclude categories from random
« on: December 28, 2007, 10:12:59 AM »
Hi @ all,
how can I exclude a category from random?

Best, Chris.

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Exclude categories from random
« Reply #1 on: December 28, 2007, 03:28:14 PM »
Exclude random cat is same of exclude cat in ACP - > Categories - > Add / Edit Categories. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

skiemor

  • Guest
Re: Exclude categories from random
« Reply #2 on: December 28, 2007, 03:37:52 PM »
Hi, Thunderstike,
ACP is configured. Only members can see "songs". But the mp3.gif in random disturbs me. ;-)

Chris.

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Exclude categories from random
« Reply #3 on: December 28, 2007, 03:50:36 PM »
Ok so ... no MP3 file in random ?
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

skiemor

  • Guest
Re: Exclude categories from random
« Reply #4 on: December 28, 2007, 04:04:48 PM »
excact, mp3.gif will shown for members in random and a don't like this, because it's no bird"pic". ;-)

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Exclude categories from random
« Reply #5 on: December 28, 2007, 04:39:54 PM »
Hum ... ok so quick way is this -

in includes/functions.php file,

find:

Code: [Select]
while ($row = $site_db->fetch_array($result)) {
      $random_image_cache[$row['cat_id']] = $row;
}

replace:

Code: [Select]
while ($row = $site_db->fetch_array($result)) {
   if (!eregi("\.mp3$", get_basefile(stripslashes(trim($row['image_thumb_file'])))) || !eregi("\.mp3$", get_basefile(stripslashes(trim($row['image_media_file']))))) {
      $random_image_cache[$row['cat_id']] = $row;
  }
}
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

skiemor

  • Guest
Re: Exclude categories from random
« Reply #6 on: December 28, 2007, 04:56:06 PM »
Oki, I changed it. I wonder, why you have for all problems a solution?! ;-)

It's now a "quick" solution. How looks solution with code, for example: "don't show cat 1, 2, 3" in php :lol:
May be I want to exclude a pic-cat too.

I found in MOD random.php a good looking description, but it's for external only?

Chris

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Exclude categories from random
« Reply #7 on: December 28, 2007, 05:19:09 PM »
Quote
May be I want to exclude a pic-cat too.

In includes/functions.php file,

find:

Code: [Select]
WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND c.cat_id = i.cat_id

change ($cat_id_sql) for: (1, 2, 3, 4) . ;)

Note: If keep last change for MP3 with new change, MP3 is still no show - exclude cat or no exclude (axcept if reverse MP3 step and use new step for exclude). ;)
Note2: If exclude cat from ACP after edit new change, is no response. Only if use $cat_id_sql for ACP. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

skiemor

  • Guest
Re: Exclude categories from random
« Reply #8 on: December 28, 2007, 05:32:05 PM »
Oki, returned mp3 step and use new code.
And know: If I upload mp3-files, they will be shown in "Newest images". I change the date to get them out, but this is a bad solution.
How to code similiar to exclude mp3 from "Newest images" like code for random?

Chris.


Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Exclude categories from random
« Reply #9 on: December 28, 2007, 05:35:34 PM »
In index.php file,

find:

Code: [Select]
while ($image_row = $site_db->fetch_array($result)) {
    if ($count == 0) {

replace:

Code: [Select]
while ($image_row = $site_db->fetch_array($result)) {
  if (!preg_match("/\.mp3/", get_basefile(stripslashes(trim($image_row['image_thumb_file'])))) || !preg_match("/\.mp3/", get_basefile(stripslashes(trim($image_row['image_media_file']))))) {
    if ($count == 0) {

find:

Code: [Select]
$count = 0;
    }
  } // end while

replace:

Code: [Select]
$count = 0;
    }
  }
  } // end while
« Last Edit: August 27, 2011, 01:57:16 PM by thunderstrike »
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

skiemor

  • Guest
Re: Exclude categories from random
« Reply #10 on: December 28, 2007, 09:24:17 PM »
Thanks but last code crashs my site. ;-)
I believe, that this code works, but not in my sites.

Chris.

skiemor

  • Guest
Re: Exclude categories from random
« Reply #11 on: December 28, 2007, 09:46:44 PM »
Quote
May be I want to exclude a pic-cat too.

In includes/functions.php file,

find:

Code: [Select]
WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND c.cat_id = i.cat_id


Quote
change ($cat_id_sql) for: (1, 2, 3, 4) . ;)

Note: If keep last change for MP3 with new change, MP3 is still no show - exclude cat or no exclude (axcept if reverse MP3 step and use new step for exclude). ;)
Note2: If exclude cat from ACP after edit new change, is no response. Only if use $cat_id_sql for ACP. ;)

That works, but if "choosen" a pic from excluded cat, this pic will not shown (right) and below the headline "Random picture" is nothing. ;-) The query must be "search without excluded cats", not only don't show pics of these cats.
« Last Edit: December 28, 2007, 11:30:37 PM by skiemor »

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Exclude categories from random
« Reply #12 on: December 28, 2007, 10:53:44 PM »
Quote
Thanks but last code crashs my site.

Is say for crash from server ?
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

skiemor

  • Guest
Re: Exclude categories from random
« Reply #13 on: December 28, 2007, 11:22:49 PM »
No, sorry, layout crashs. ;-)

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Exclude categories from random
« Reply #14 on: December 28, 2007, 11:31:51 PM »
1, 2, 3, 4 value exist in CATEGORIES_TABLE and IMAGES_TABLE (cat_id field) + image of inactive category is inactive too ? If inactive category with active image, is no work sure.  :mrgreen:
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?