4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: Sun Zaza on December 21, 2008, 01:17:47 PM
-
Hi all,
I believe I have a very nice mod request for 4images:
On my video site I have an additional field with the video duration: {image_duration}.
How can the users look for videos (Search) which the duration is more than 5 minutes? (That was an example).
Is that possible?
Is there any other mod on this forum to tweak? :wink:
Thanks in advance,
-
you can start with this tutorial:
[Tutorial] Making additional field searchable (http://www.4homepages.de/forum/index.php?topic=1313.msg5562#msg5562)
-
Hi Vano,
I use this mod for more than 2 years, but how can the users look for videos (Search) which the duration is more than 5 minutes?
I cannot get your point.
-
In what format your duration time is stored in the database? if it's text or varchar then its probably wont work at all...unless its stored as a number (int, mediumint, etc)...
-
You are wright V@no, It is text. I will change now to int.
Do you want me to change something else?
-
I don't know how your code work, but if you change to int then you can't use any other characters but the numbers. so time 4:27 will need to be converted to seconds: 267
-
I am using now TIME(). So instead of 00:00 I have 00:00:00
-
Ok, lets try this. I'm not quiet sure what exactly is stored in your database in image_duration, but I'll assume it stores time in seconds, so if video duration is 4:27 in the database it stored number 267 and not huge timestamp number.
In search.php find:
if (!empty($search_id)) {
Insert above:
if (isset($HTTP_GET_VARS['image_duration']) || isset($HTTP_POST_VARS['image_duration'])) {
$image_duration = isset($HTTP_POST_VARS['image_duration']) ? trim($HTTP_POST_VARS['image_duration']) : trim($HTTP_GET_VARS['image_duration']);
}
else {
$image_duration = 0;
}
### convert string into seconds. asuming string format is h:m:s (also accepted m:s or simply s)
$t = explode(":", $image_duration);
$c = 3-count($t);
for($i = 0; $i < $c; $i++) array_unshift($t, 0); ### make sure array has at least 3 values
$c = count($t);
$image_duration = gmmktime(intval($t[$c-3]), intval($t[$c-2]), intval($t[$c-1]), 1, 1, 1970); ### this will return number in seconds.
if ($image_duration && $show_result == 1) {
$search_id['image_duration'] = $image_duration;
}
if (!empty($sql_where_query)) {
Insert above:
if (!empty($search_id['image_duration']))
{
$sql_where_query .= "AND image_duration >= ".$search_id['image_duration'];
}
-
The time is stored as this format: 00:00:00
Check the screenshot please.
Is that a problem?
-
hmmmm then it can't be int type of the field...which bring us back to my second reply...
Try remove from my code above:### convert string into seconds. asuming string format is h:m:s (also accepted m:s or simply s)
$t = explode(":", $image_duration);
$c = 3-count($t);
for($i = 0; $i < $c; $i++) array_unshift($t, 0); ### make sure array has at least 3 values
$c = count($t);
$image_duration = gmmktime(intval($t[$c-3]), intval($t[$c-2]), intval($t[$c-1]), 1, 1, 1970); ### this will return number in seconds.
and see if it still works.
-
Ok I done it. But how can I test it?
See the attachment please:
The URL: http://www.jogabonito.nl/search.php
-
well, since your time duration format is 00:00:00 the visitor must enter the needed duration manually - needs a new input field for that.
-
I was also thinking about that. It should be something like your other mod: [MOD] Search between specifyed date http://www.4homepages.de/forum/index.php?topic=6182.0 (http://www.4homepages.de/forum/index.php?topic=6182.0)
I will give it a try. Your never know...
-
Hey Cruxy are you manually adding the duration of your videos or have you found a way to automate the process? I would love to implement an {image_duration} tag as long as it was an automatic process.
Best Regards
-
Unfortunately not. I add manually the video duration (For youtube video's).
You can see it here: www.jogabonito.nl.
For the video on your server, Maybe you can ask V@no.
-
Thank you Cruxy for the quick reply.
Best Regards