Author Topic: The gallery shows not the 0 (Zero).  (Read 5859 times)

0 Members and 1 Guest are viewing this topic.

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
The gallery shows not the 0 (Zero).
« on: December 28, 2008, 01:42:49 AM »
Hi,

I have a small problem.

I added an additional field to my gallery with this code:

Code: [Select]
alter table 4images_images add column image_hot_hits int (10) DEFAULT '0' NOT NULL
On the details page shows the value {image_hot_hits} only when it has a value of 1 or more.

That means the gallery shows never the 0 (Zero).

I have to show that on the gallery.

What did I do wrong?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: The gallery shows not the 0 (Zero).
« Reply #1 on: December 28, 2008, 06:22:07 AM »
what did you add in includes/db_field_definitions.php ?
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 Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: The gallery shows not the 0 (Zero).
« Reply #2 on: December 28, 2008, 06:23:40 AM »
Code: [Select]
$additional_image_fields['image_hot_hits'] = array($lang['image_hot_hits'], "text", 0);

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: The gallery shows not the 0 (Zero).
« Reply #3 on: December 28, 2008, 06:26:10 AM »
Never mind that question...4images uses empty() which returns false for emptry string and for "0"

The work around is use something like this:

{ifno field_name}0{andifno field_name}{if field_name}{field_name}{endif field_name}
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 Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: The gallery shows not the 0 (Zero).
« Reply #4 on: December 28, 2008, 06:38:26 AM »
I just tried it. It is working fine. Thanks v@no.

I hope you can find a faster solution for this issue. :wink:

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: The gallery shows not the 0 (Zero).
« Reply #5 on: December 28, 2008, 06:53:43 AM »
Hi V@no,

Is it normal that the value 0 of the additional field {image_hot_hits} is showing on the ACP (Edit image) and not on the gallery?

PS: Before using {ifno field_name}0{andifno field_name}{if field_name}{field_name}{endif field_name}

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: The gallery shows not the 0 (Zero).
« Reply #6 on: December 28, 2008, 07:02:26 AM »
Yes, it's expected. It only affects templates. (ACP doesn't use templates)

http://php.net/manual/en/function.empty.php
Quote
Returns FALSE if var  has a non-empty and non-zero value.

The following things are considered to be empty:

    * "" (an empty string)
    * 0 (0 as an integer)
    * "0" (0 as a string)
    * NULL
    * FALSE
    * array() (an empty array)
    * var $var; (a variable declared, but without a value in a class)
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 Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: The gallery shows not the 0 (Zero).
« Reply #7 on: December 28, 2008, 07:06:32 AM »
Ok I understand, but what is the different between image_hits and image_hot_hits? I just want to understant.

The image_hits shows 0 if nobody has see the image yet.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: The gallery shows not the 0 (Zero).
« Reply #8 on: December 28, 2008, 07:47:00 AM »
image_hits processes by a separate part of code then additional fields.
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)