View Full Version : date and time rollover for thumbnails
onelowerlight
08-02-2007, 04:16 AM
Hello everyone! I'm a little new here, so please have patience with me if I'm not posting this in the right place. I just set up my blog using v1.6.0, and it's been really awesome! I'm not much of an expert at web design, but so far I've been able to figure out everything that I need to know to set my blog up the way I want it. However, I have a modification that I'd like to make and I'm not sure how to do it.
I would like to modify the thumbnails in my archive page so that when the mouse rolls over them, not just the name of the photo shows up, but the date (day and month) shows up too. I think I have to do more than just edit browse_template.html but I'm not sure how to do it.
My blog is located here (http://www.onelowerlight.com/photos) and this what's on my "general info" page:
Pixelpost Information
You are running Pixelpost version: 1.6.0 (in the right direction) - April 2007
Latest Pixelpost version: You have the newest version of Pixelpost!
Looking for help or want to give feedback, please step into Pixelpost forum.: forum.pixelpost.org
Host Information
URL http://www.onelowerlight.com/photos/admin/index.php
PHP-version 5.1.6 (Pixelpost's min requirement: PHP version: 4.3.0 )
Session save path is empty!!
MySQL version 5.0.27-standard-log (Pixelpost's min requirement: MySQL: 3.23.58 )
GD-lib bundled (2.0.28 compatible) with JPEG support
File Uploads to Pixelpost site are possible.
Server Software Apache/1.3.37 (Unix) mod_fastcgi/2.4.2 mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 FrontPage/5.0.2.2635.SR1.2 mod_ssl/2.8.28 OpenSSL/0.9.7a PHP-CGI/0.1b
EXIF Pixelpost is using exifer v1.5 for EXIF-information.
Paths
Guessed imagepath: /home/onelower/public_html/photos/images/
Configured Imagepath: ../images/
Image Directory: OK - Can we write to the directory? YES. Current CHMOD: 0755
Thumbnails Directory: OK - Can we write to the directory? YES. Current CHMOD: 0755
Language Directory: OK
Addons Directory: OK
Includes Directory: OK
Templates Directory: OK
Thanks!
OLL
Dkozikowski
08-02-2007, 12:37 PM
You are correct that this involves deeper editing then just template files.
You will need to modify the core pixelpost files.
When doing this we call it a "hack".
Hacks are a pain because every-time you upgrade pixelpost you will have to re-apply all of them to keep the functionality the same.
So, anyway, with that said:
Open the file called functions_browse.php located within your includes/ folder.
Find:
while(list($count,$id,$title,$name,$datetime) = mysql_fetch_row($query))
{
if( $count != $lookingfor) continue; // Major hack for the browse filters.
$title = pullout($title);
$title = htmlspecialchars($title,ENT_QUOTES);
$thumbnail = "thumbnails/thumb_$name";
$thumb_output .= "<a href=\"$showprefix$id\"><img src=\"$thumbnail\" alt=\"$title\" title=\"$title\" class=\"thumbnails\" /></a>";
}
Replace with:
$dateFormat = "Y.m.d"; // EG: 2007.05.09 (for a complete list of date characters, http://www.php.net/date)
while(list($count,$id,$title,$name,$datetime) = mysql_fetch_row($query))
{
if( $count != $lookingfor) continue; // Major hack for the browse filters.
$timestamp = strtotime($datetime);
$timestamp = date($dateFormat, $timestamp);
$title = pullout($title);
$title = htmlspecialchars($title,ENT_QUOTES);
$thumbnail = "thumbnails/thumb_$name";
$thumb_output .= "<a href=\"$showprefix$id\"><img src=\"$thumbnail\" alt=\"$title - $timestamp\" title=\"$title - $timestamp\" class=\"thumbnails\" /></a>";
}
Notice
$dateFormat = "Y.m.d"; // EG: 2007.05.09 (for a complete list of date characters, http://www.php.net/date)
By changing the above Y.m.d you can change the way the date / time is displayed. Follow the link, http://www.php.net/date , for more info.
onelowerlight
08-02-2007, 04:03 PM
Thanks! I tried it out, though, and it didn't quite work. Rolling over the thumbnails still only displays the title of the photo. I'm not exactly sure why it didn't work. This is the modification I made:
$dateFormat = "Y.m.d"; // EG: 2007.05.09 (for a complete list of date characters, http://www.php.net/date)
while(list($count,$id,$title,$name,$datetime) = mysql_fetch_row($query))
{
if( $count != $lookingfor) continue; // Major hack for the browse filters.
$timestamp = strtotime($datetime);
$timestamp = date($dateFormat, $timestamp);
$title = pullout($title);
$title = htmlspecialchars($title,ENT_QUOTES);
$thumbnail = "thumbnails/thumb_$name";
$thumb_output .= "<a href=\"$showprefix$id\"><img src=\"$thumbnail\" alt=\"$title - $timestamp\" title=\"$title - $timestamp\" class=\"thumbnails\" /></a>";
}
Dkozikowski
08-02-2007, 10:13 PM
It should work. I tested before i posted the code.
Make sure you replaced the old code completely with the new code.
onelowerlight
08-03-2007, 12:01 AM
No, sorry, I tried copying and pasting the whole thing, and it still doesn't quite work.
Maybe this will help: I'm using the dolichocephale template, and the html code for browse_template.html looks like this where the thumbnails all occur:
<div id="categorie">
<p><BROWSE_MONTHLY_ARCHIVE_PAGED> <BROWSE_CATEGORIES_PAGED> <CATEGORY_OR_DATE_NAME_PAGED_ARCHIVE></p>
<div id="catthumbs"><THUMBNAILS_WHOLE_PAGED>
<p>page <THUMBNAILS_PAGES_LINKS></p></div>
</div>
Do I need to use a different tag for the thumbnails?
Dkozikowski
08-03-2007, 01:20 AM
Ahh. That's why. You are not using the standard pixelpost browse template tag.
Open the file called paged_archive.php located within your addons/ folder.
Find
$query = "SELECT id, headline, image FROM {$pixelpost_db_prefix}pixelpost
WHERE (datetime<='$cdate')
GROUP BY id
ORDER BY datetime DESC" .$limit;
}
$query = mysql_query($query);
//---------------------------- Making thumbs row
// for each record ...
while(list($id,$title,$name) = mysql_fetch_row($query))
{
// from the thumbnail row. This could be build by tables too.
$title = pullout($title);
$thumbnail = "thumbnails/thumb_$name";
$thumb_output .= "<a href='$PHP_SELF?showimage=$id'><img src='$thumbnail' alt='$title' title='$title' class='thumbnails' /></a>";
} //end while
Replace with
$query = "SELECT id, datetime, headline, image FROM {$pixelpost_db_prefix}pixelpost
WHERE (datetime<='$cdate')
GROUP BY id
ORDER BY datetime DESC" .$limit;
}
$query = mysql_query($query);
//---------------------------- Making thumbs row
$dateFormat = "Y.m.d"; // EG: 2007.05.09 (for a complete list of date characters, http://www.php.net/date)
// for each record ...
while(list($id,$datetime,$title,$name) = mysql_fetch_row($query))
{
$timestamp = strtotime($datetime);
$timestamp = date($dateFormat, $timestamp);
// from the thumbnail row. This could be build by tables too.
$title = pullout($title);
$thumbnail = "thumbnails/thumb_$name";
$thumb_output .= "<a href='$PHP_SELF?showimage=$id'><img src='$thumbnail' alt='$title - $timestamp' title='$title - $timestamp' class='thumbnails' /></a>";
} //end while
Again, Notice
$dateFormat = "Y.m.d"; // EG: 2007.05.09 (for a complete list of date characters, http://www.php.net/date)
By changing the above Y.m.d you can change the way the date / time is displayed. Follow the link, http://www.php.net/date , for more info.
onelowerlight
08-03-2007, 03:27 AM
Thanks! It works great! Thanks for the link, too, it's really useful for programming dates and times!
onelowerlight
08-04-2007, 03:59 AM
Wait, now whenever I try to access a category or a different month, the thumbnail images won't show up, and the year displayed goes back to 1969! Does anyone know why this is happening and how to fix it? Sorry to be annoying!
onelowerlight
08-04-2007, 04:00 AM
It does work fine when you access the archive page directly, and displays the year fine; it's just when you try to access a month or a category on the drop down menu that it does this weird thing.
Dkozikowski
08-04-2007, 10:24 AM
The errors exist because of the modification you made or they remain even without modification?
onelowerlight
08-05-2007, 03:45 AM
It's the modification. They work fine with the original paged_archive.php.
Dkozikowski
08-05-2007, 01:48 PM
Ok, i figured out why.
There were 2 problems.
Problem 1, we needed to add a few more queries to pull out the datetime and problem 2, using the variable $datetime in the while(list( was causing page number issues.
I've made the necessary changes and uploaded a new paged_archive.php file for you.
You can get it here (http://dwilkinsjr.com/public/pixelpost/forumFiles/paged_archive.zip).
onelowerlight
08-05-2007, 06:07 PM
Thanks! It works great!
vBulletin® v3.7.3, Copyright ©2000-2013, Jelsoft Enterprises Ltd.