4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: Sun Zaza on November 08, 2007, 11:57:59 PM
-
Hi guys,
I have the hole day problems with my gallery and now I have to solve something difficult for me:
I add two image additional fields:
{date_start} and {date_end}
Both are working fine on details.html
First question:
I want to add a new array {date2}
{date2}= {date_end} - {date_start}
I want the answer in days
Second question:
I want to add a new array {date3}
{date3}= today - {date_start}
I want the answer also in days
It is now midnight and I can not sleep because this issue. :cry:
Many thanks in advance for any help and/or explain,
Cruxy
-
You need edit includes/functions.php file for this in show_image function ...
Please post all additional image fields name with request (date start, date end) and I code. ;)
-
Thank you Thunderstrike,
Here we go:
The image additional fields are already exist:
{date_start} and {date_end}
So I want a new array
{date2}= {date_end} - {date_start} (days, for example: 30 days)
I want also:
{date3}= today - {date_start} (days, for example: 30 days)
Thank yoy in advance,
Cruxy
-
Ok now ... what field type is date start and end ? (int, date) ? Please post more detail with this ...
-
Oke,
{date_end} and {date_start} are both are type date (I can change it if you want to).
Do you need more info? :)
-
// Step 1
In details.php file,
find:
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
add before:
if (isset($image_row['date_start']) && !empty($image_row['date_start']) && isset($image_row['date_end']) && !empty($image_row['date_end'])) {
$image_start_date = $image_row['date_start'];
$image_end_date = $image_row['date_end'];
if (preg_match("/(\d{2})-(\d{2})-(\d{4})/", $image_start_date, $start)) {
if (preg_match("/(\d{2})-(\d{2}-(\d{4}))/", $image_end_date, $end)) {
if ($start[1] > date("d")) {
$image_real_date_today = $start[1] - date("d");
} elseif ($start[1] < date("d")) {
$image_real_date_today = date("d") - $start[1];
} elseif ($start[1] == date("d")) {
$image_real_date_today = $start[1];
} elseif ($end[1] > date("d")) {
$image_real_date_today = $end[1] - date("d");
} elseif ($end[1] < date("d")) {
$image_real_date_today = date("d") - $end[1];
} elseif ($end[1] == date("d")) {
$image_real_date_today = date("d") - $end[1];
}
$image_real_date_end_start = $end[1] - $start[1];
}
}
}
// Step 1.1
Find:
"lang_file_size" => $lang['file_size'],
add after:
"date2" => (isset($image_real_date_end_start)) ? $image_real_date_end_start : "",
"date3" => (isset($image_real_date_today)) ? $image_real_date_today : "",
In details.html file, use: {date2} and {date3} .
-
Sorry, I fix post. You no work with int but date. ;)
-
Hi Thunderstrike,
It did not works yet!!!
There is something wrong with the date.
In edit image I put 01-10-2007 but in details.htm I get 0000-00-00
and when I put 2007-10-01 I get 2007-10-01.
I want to use actually 01-10-2007.
How can I change the format of date? :roll:
-
How can I change the format of date?
Re-create date start and date end with int type. No with date field. :mrgreen:
I fix post in some min ...
[edit] - I fix for show with int microtime field. If set date in microtime - is quick way. ;)
-
Hi Thunderstrike, I don't understand you. Have you already updated the code or do I have to wait :roll:
-
The code is update but you need add date (start and end) with microtime. Same way image_date is inject. ;)
-
Ok, I find other. What is date format in ACP - > Setting you have ? (Ex: d-m-Y) ...
If say format, I can code. ;)
-
Ok, I edit code for step 1. Date format is: Y-m-d . If is no right - is ok - I edit. ;)
-
Hi Thunderstrike,
Here we go again :D
I can not test the code because we have to solve first the problem of showing the dates on the details.
I will explain:
The additional field {date_start} = 01-10-2007 (At the edit image "ACP")
On the details.html is showing only 1
On the database I used: int(11) NO 0 (The same as {image_hits}).
I do not understand why? :roll:
See screenshots
-
The additional field {date_start} = 01-10-2007 (At the edit image "ACP")
Ok, so I fix date format in code now. ;)
On the database I used: int(11) NO 0 (The same as {image_hits}).
Oh ... this is right ... create the date_start and date_end field with date again. I miss for say this after last fix. :oops:
-
No problem :)
I still can not test the code because when I changed int to date I get the date of {date_start} like: 0000-00-00 instead of 01-10-2007
I am testing on a very fresh gallery
-
I still can not test the code because when I changed int to date I get the date of {date_start} like: 0000-00-00 instead of 01-10-2007
Please decide the date format range. Is year before or year after ?
-
I want to use :arrow: 01-10-2007
What strange is that {image_date} workt perfect even you edit the date, but the date of the additional field NOT
-
I want to use :arrow: 01-10-2007
Ok so date format is correct. ;)
What strange is that {image_date} workt perfect even you edit the date, but the date of the additional field NOT :roll:
image_date is create with int.
For additional field, is create with int or with date ? Is no matter for me but you need say ...
-
The additional field {hits_start} is created with DATE "Type: Date, Null: No" (as you asked me to do).
Ok so date format is correct.
On details is date 0000-00-00 is not correct. First the format is not good and second I see only zero's instead of 01-10-2007
Something wrong with the DATE additional fields? or in the database? :?:
-
On details is date 0000-00-00 is not correct. First the format is not good and second I see only zero's instead of 01-10-2007 :roll:
Please STOP use roll eyes :!:
Now, is say you see format with year before. You no use my fix. Use it. I say in last post - I fix my code for year at end. Year in code is now: d-m-Y
Something wrong with the DATE additional fields? or in the database?
Nothing is wrong with database ... you add date in field ? If see 00-00-0000 (or 0000-00-00 if no use my fix), is mean you no add nothing in field. Field is empty. :?
-
Please STOP use roll eyes
Oh sorry I did not mean that!
Nothing is wrong with database ... you add date in field ? If see 00-00-0000 (or 0000-00-00 if no use my fix), is mean you no add nothing in field. Field is empty.
I am trying to figuur out the problem of the database. I go back to you when I find something :?
-
Database is fine. You need for set date (is good if create with DATE field type in phpmyadmin) and set correct date in ACP - > Images - > Edit images page for image you click.
1 - Submit form and server is process date.
2 - Check for see if still 00-00-0000 for return value.
-
I think I have the unswer but NOT the solution.
In phpmyadmin I created a date. Everything is fine till now because the right date is showing in the details.
BUT when I tried to open this image in ACP, the date changed to 0000-00-00.
Now we know for sure that nothing wrong with the database. There is a miscommunication between {hits_start} (Additional field) and the database.
I beleave that the database doesn't understand that {hits_start} is a date!
Maybe we have to change or to add something in function.php?
-
Good news :)
The problem is solved, but I still get the format: 2007-10-01. (phpmyadmin does not accept the format 01-10-2007)
How can I change it?
NOTE: When I we change the format I will start test in you code!
-
I did some research via GOOGLE and finaly I have the unswer.
phpmyadmin have problems with dates, so it accecpt only this format: 0000-00-00 (INPUT).
But if you want to show the format 00-00-0000 (OUTPUT) you need to use:
1 - The explode function on each date in your file and then just insert into the mysql table in the format yyyy-mm-dd.
OR
<?php
$myinput='12/15/2005';
$sqldate=date('Y-m-d',strtotime($myinput));
echo $sqldate;
?>
PS: I tried to figure out how the 4images shows the format 00-00-0000, but no luck yet!!!
Can you help me in that?
Many thanks in advance,
Cruxy
-
This is in 4images with format_date function so use:
$image_start_date = format_date($config['date_format'], $image_row['date_start']);
$image_end_date = format_date($config['date_format'], $image_row['date_end']);
-
I am still fighting to make it work.
$image_start_date = format_date($config['date_format'], $image_row['date_start']);
$image_end_date = format_date($config['date_format'], $image_row['date_end']);
I did not test the first code yet, because I want to change first the format of {date_start} on the details.
Listen, On functions.php I added this line:
"date_start" => format_date($config['date_format']." ".$config['time_format'],$image_row['date_start']), under
"image_date" => format_date($config['date_format']." ".$config['time_format'],$image_row['image_date']),
NO format changing yet!!!
-
If want to use date_start and date_end with strtotime, you need set field by int and no by date for keep right date format with 4images.
-
Believe it or not. I was busy with this matter since this morning. I tried all tricks, but no luck yet!
I could not change the format of the {date_start}, but it is not very important at the moment.
Here we go again:
{date_start} and {date_end} are TYPE: Date.
The dates are showing in the details.html, but {date2} and {date3} NOT!!!
Do you have to change/add something in the code?
if (isset($image_row['date_start']) && !empty($image_row['date_start']) && isset($image_row['date_end']) && !empty($image_row['date_end'])) {
$image_start_date = $image_row['date_start'];
$image_end_date = $image_row['date_end'];
if (preg_match("/(\d{2})-(\d{2})-(\d{4})/", $image_start_date, $start)) {
if (preg_match("/(\d{2})-(\d{2}-(\d{4}))/", $image_end_date, $end)) {
if ($start[1] > date("d")) {
$image_real_date_today = $start[1] - date("d");
} elseif ($start[1] < date("d")) {
$image_real_date_today = date("d") - $start[1];
} elseif ($start[1] == date("d")) {
$image_real_date_today = $start[1];
} elseif ($end[1] > date("d")) {
$image_real_date_today = $end[1] - date("d");
} elseif ($end[1] < date("d")) {
$image_real_date_today = date("d") - $end[1];
} elseif ($end[1] == date("d")) {
$image_real_date_today = date("d") - $end[1];
}
$image_real_date_end_start = $end[1] - $start[1];
}
}
}
"date2" => (isset($image_real_date_end_start)) ? $image_real_date_end_start : "",
"date3" => (isset($image_real_date_today)) ? $image_real_date_today : "",
See screenshot please!
-
I could not change the format of the {date_start}, but it is not very important at the moment.
Is important. If no change, is no work with strtotime.