View previous topic :: View next topic |
Author |
Message |
alex_t_king
Joined: 09 Oct 2002 Posts: 194
|
Posted: Fri May 16, 2003 9:50 pm Post subject: Since Last Visit v 2.3 |
|
|
I've posted version 2.3 of my Since Last
Visit hack on my web site. The hack shows how many new posts and
comments have been added since the visitor previous visit and indicates
which are new.
This release fixes a bug where I wasn't properly accounting for the server time difference in the database. (thanks lcfwebsite)
It's available <a href="http://www.alexking.org/?content=software/b2/last_visit.php" target="_blank" class="postlink">here</a>.
I also have other <a href="http://www.alexking.org/software/b2/" target="_blank" class="postlink">b2 hacks</a> if you get curious. _________________ Yahoo! Messenger ID: alex_t_king |
|
Back to top |
|
 |
lcf
Joined: 05 May 2003 Posts: 92 Location: Malaysia
|
Posted: Fri May 16, 2003 10:00 pm Post subject: |
|
|
Thanks, Alex for great help.
One feature request here:
how about add links to 'X new posts' and 'Y comments', so that it will list/display the new posts or comments when clicking on the links?
I found it useful that visitors do not need to search through the blogs for new posts or comments  _________________ LcF
http://weblog.lcfwebsite.com |
|
Back to top |
|
 |
alex_t_king
Joined: 09 Oct 2002 Posts: 194
|
Posted: Fri May 16, 2003 10:06 pm Post subject: |
|
|
Sounds like a feature like that could bump this to 3.0.
I'll look at doing this when I have some time, shouldn't be hard. The trickier part is how/where to display the links. I guess if I just make functions that print the links people can put them whereever they want. Some kind of DHTML hide/show functionality on the list (click the '3 new posts' link to toggle) would probably be a good way to go. _________________ Yahoo! Messenger ID: alex_t_king |
|
Back to top |
|
 |
lcf
Joined: 05 May 2003 Posts: 92 Location: Malaysia
|
Posted: Sun May 18, 2003 11:47 pm Post subject: |
|
|
Is there anyway to show New post indicator beside Categories' name?
I mean in the Categories list, it will show a 'new' indicator in every category that has new post.
It will be nice, too  _________________ LcF
http://weblog.lcfwebsite.com |
|
Back to top |
|
 |
alex_t_king
Joined: 09 Oct 2002 Posts: 194
|
Posted: Mon May 19, 2003 6:02 am Post subject: |
|
|
I don't know, seems like it would clutter it up a bit more than I'd like. You should be able to use the current code as a model if you want to do this. _________________ Yahoo! Messenger ID: alex_t_king |
|
Back to top |
|
 |
lcf
Joined: 05 May 2003 Posts: 92 Location: Malaysia
|
Posted: Thu May 22, 2003 2:27 pm Post subject: |
|
|
By 'copying' Alex Since Last Visit codes, I wrote another function for new post in Category. Just simply paste the following function into Alex's Since_Last_Visit hack.
Code: |
//LCF: new post in category
function lcf_newpost_category($category = -1, $html = '<img src="ak-img/new_1.gif" alt="New post since your last visit." />') {
if ($category != -1){
global $tableposts;
global $ak_last_visit;
if (isset($ak_last_visit)) {
$last_visit = date("Y-m-d H:i:s", $ak_last_visit);
$query = "SELECT post_date from $tableposts WHERE post_category = $category AND post_date > '"."$last_visit"."'" ;
$result = mysql_query($query);
if ($found = mysql_fetch_row($result)){ echo $html; }
}
}
}
|
Example: Code: | <?php lcf_newpost_category(1) ?> |
this will check if there any new post in category with ID 1, and display a flag if there is new post. _________________ LcF
http://weblog.lcfwebsite.com |
|
Back to top |
|
 |
alex_t_king
Joined: 09 Oct 2002 Posts: 194
|
Posted: Thu May 22, 2003 6:36 pm Post subject: |
|
|
Nice work, if you want to make a minor speed improvement to your site at some point you may want to integrate this into the category code to minimize queries. _________________ Yahoo! Messenger ID: alex_t_king |
|
Back to top |
|
 |
Eyevan
Joined: 16 Aug 2002 Posts: 18
|
Posted: Wed Jun 18, 2003 12:00 am Post subject: |
|
|
Hi,
Can you make a more detailed tutorial on how to install this? It's really confusing for me... |
|
Back to top |
|
 |
alex_t_king
Joined: 09 Oct 2002 Posts: 194
|
|
Back to top |
|
 |
dodo
Joined: 25 Jan 2002 Posts: 35
|
Posted: Thu Jun 19, 2003 3:45 pm Post subject: |
|
|
great hack! one suggestion: maybe you can make the expiration time a variable? i mean it depends on how fast a person reads his/her/ own comments.. and how many s/he gets. one hour is definitely too long for me. i changed it to 10 minutes on mine but others might not be able to read the code and change it so easily. it will be nice it's a variable. _________________ http://pure-essence.net
b2 rocks |
|
Back to top |
|
 |
Eyevan
Joined: 16 Aug 2002 Posts: 18
|
Posted: Thu Jun 19, 2003 5:22 pm Post subject: |
|
|
I really want to just install that "New" image function for both the post and the comments... |
|
Back to top |
|
 |
alex_t_king
Joined: 09 Oct 2002 Posts: 194
|
Posted: Thu Jun 19, 2003 7:29 pm Post subject: |
|
|
dodo wrote: | great hack! one suggestion: maybe you can make the expiration time a variable? .... it will be nice it's a variable. |
Um, it *is* a variable already...
function ak_set_last_visit_cookie($use_session = 1, $hours = 1) {...
The $hours var is the one you want to set. It is in hours, so you can set it as a decimal if you want to use a time period less than an hour. Keep in mind posts that occur after the 'current visit' will still have a NEW indicator, that is just how long the NEW indicators on all of the new posts and comments will be shown.
For example, if I go to your site and there are 20 new posts and the time is set to 10 minutes, I might get through 5 posts in the 10 minutes then all of the NEW indicators will dissapear because the time is only set to 10 minutes. _________________ Yahoo! Messenger ID: alex_t_king |
|
Back to top |
|
 |
alex_t_king
Joined: 09 Oct 2002 Posts: 194
|
Posted: Thu Jun 19, 2003 7:31 pm Post subject: |
|
|
Eyevan wrote: | I really want to just install that "New" image function for both the post and the comments... |
Ok, so what part of the directions is confusing to you? _________________ Yahoo! Messenger ID: alex_t_king |
|
Back to top |
|
 |
sabotage
Joined: 15 Jul 2003 Posts: 36
|
Posted: Wed Sep 03, 2003 11:26 am Post subject: |
|
|
alex_t_king wrote: | Nice work, if you want to make a minor speed improvement to your site at some point you may want to integrate this into the category code to minimize queries. |
i was thinking the same....but er...how do i do this? i thought about tinkering with the list_cats function, and make it so that it would check each category for new posts. should i do this with a for loop for each category? i know it's a newbie question, but i need the confirmation or a tiny push in the right direction
i'm not afraid to try things out myself, but it makes it a lot easier if i know what NOT to touch or do in advance |
|
Back to top |
|
 |
alex_t_king
Joined: 09 Oct 2002 Posts: 194
|
Posted: Wed Sep 10, 2003 12:17 am Post subject: |
|
|
you'll probably need to modify the list_cats function and include
MAX(post_date) as latest_post
or similar in the SELECT statement, then use that date as a comparison against the date in the cookie. _________________ Yahoo! Messenger ID: alex_t_king |
|
Back to top |
|
 |
|