boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

A couple of hacks...
Goto page 1, 2  Next
 
Post new topic   Reply to topic    boardom Forum Index -> Hacks
View previous topic :: View next topic  
Author Message
alex_t_king



Joined: 09 Oct 2002
Posts: 194

PostPosted: Mon Nov 04, 2002 9:07 am    Post subject: A couple of hacks... Reply with quote

I've written a couple of hacks and made them available on my site. The top three were requested in the "How To" section of the forum.

- Set a cookie so that you can show your visitors which posts and comments are new since their last visit.

- Show previous/next arrows on the calendar.

- Show that day's post titles on mouseover of a day in the calendar.

- Show the number of posts at the end of each category name: General (25)

- Show the number of posts at the end of each month name: November (2)
(this only works in monthly archive mode)

If you find any problems, bugs, hidden dependencies, etc. trying to use these - let me know.
_________________
Yahoo! Messenger ID: alex_t_king
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
GamerZ



Joined: 15 May 2002
Posts: 537
Location: Singapore

PostPosted: Mon Nov 04, 2002 10:01 am    Post subject: Reply with quote

erm i got 1 bug regarding the last visit hack
here is the problem

Let say user visit my page @ 12.35pm, he close the browser and later at maybe about 12.40pm.

He come in again, the last visit will display as 12.35pm, nothing wrong with that. He closes the browser again.

But when he came in for the 3rd time, the last visit shld display at 12.40pm but it display at 12.35pm.

Subsequently for the 4th, 5th visit the time is still at 12.35pm.
_________________

++ GamerZ.Per.Sg - Complex Simplicity
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
alex_t_king



Joined: 09 Oct 2002
Posts: 194

PostPosted: Mon Nov 04, 2002 10:23 am    Post subject: Reply with quote

hmm, I don't have that problem on my site... tested in Mozilla and IE. Make sure you hit refresh so it isn't pulling the page from cache. I've set it to always show on my site so you can test it - take a look and see if you see it working properly on my site.
_________________
Yahoo! Messenger ID: alex_t_king
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
alex_t_king



Joined: 09 Oct 2002
Posts: 194

PostPosted: Mon Nov 04, 2002 11:30 am    Post subject: Reply with quote

I had forgotten to include some instructions in the zip file, specifically the code to set the cookie. If you removed the code to set the cookie (from the old version) then it would explain why the cookie wasn't changing. That code is still needed. Grab an updated zip file or read the notes I added on the page and you should be all set.

Thanks.
_________________
Yahoo! Messenger ID: alex_t_king
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
GamerZ



Joined: 15 May 2002
Posts: 537
Location: Singapore

PostPosted: Mon Nov 04, 2002 3:07 pm    Post subject: Reply with quote

erm
u forgot to get $post_id
_________________

++ GamerZ.Per.Sg - Complex Simplicity
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
alex_t_king



Joined: 09 Oct 2002
Posts: 194

PostPosted: Mon Nov 04, 2002 6:10 pm    Post subject: Reply with quote

geesh - I'm bad at packaging these things.

Yes you can pass in the id of the post, somehow I zipped the wrong version of the ak_new_posts()/ak_new_comments() functions and it was required in that one. In the current version I've set the default of $post_id to -1 and then call the global $id (assuming we're in a loop). Funny, I got this all working just fine on my own site - from the way I've bungled trying to package these things I'm surprised the site it even running! Smile

Thanks for the help GamerZ, hopefully that is the last of it.
_________________
Yahoo! Messenger ID: alex_t_king
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
mikelittle



Joined: 11 May 2002
Posts: 376
Location: UK

PostPosted: Tue Nov 05, 2002 1:28 am    Post subject: Reply with quote

Alex,
I noticed on your site you mention "...but retaining the speedier SQL query I was using", with regard to the category count hack. However you are still using (1 + number of categories) queries. It can all be done with a single query which should be even faster.
[php:1:a6a2b227cd]<?php
// hack from http://www.adamwalker.34sp.com/index.php?p=37&more=1
function list_cats($optionall = 1, $all = 'All', $sort_column = 'cat_ID', $sort_order = 'asc',
$file = 'blah', $optiondates = 0, $optioncount = 0, $hide_empty = 1) {
global $tablecategories,$querycount, $tableposts;
global $pagenow;
global $querystring_start, $querystring_equal, $querystring_separator;
$file = ($file == 'blah') ? $pagenow : $file;
$sort_column = 'cat_'.$sort_column;
$query = " SELECT cat_ID, cat_name,";
$query .= " count(b2posts.ID) AS cat_count,";
$query .= " DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth";
$query .= " FROM $tablecategories LEFT JOIN $tableposts ON cat_ID = post_category";
$query .= " WHERE cat_ID > 0 ";
$query .= " GROUP BY post_category ";
if (intval($hide_empty) == 1) {
$query .= " HAVING cat_count > 0";
}
$query .= " ORDER BY $sort_column $sort_order, post_date DESC";

$result=mysql_query($query); // or die("Couldn't execute query $query ". mysql_error());
$querycount++;
if (intval($optionall) == 1) {
echo "\t<a href=\"".$file.$querystring_start.'cat'.$querystring_equal.'all">'.$all."</a><br />\n";
}
while($row = mysql_fetch_object($result)) {
echo "\t<a href=\"".$file.$querystring_start.'cat'.$querystring_equal.$row->cat_ID.'">';
echo stripslashes($row->cat_name)."</a>";
if (intval($optioncount) == 1) {
echo "  (".$row->cat_count.")";
}
if (intval($optiondates) == 1) {
echo "  ".$row->lastday."/".$row->lastmonth."";
}
echo "<br />\n";
}
}
[/php:1:a6a2b227cd]
Note this is a hack of the original list_cats() and includes the optional date of last post in category. I've added in your hide_empty flag.

Also my archive count of posts here also works for weeks as well as months.

Mike[url][/url]
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
alex_t_king



Joined: 09 Oct 2002
Posts: 194

PostPosted: Tue Nov 05, 2002 3:44 am    Post subject: Reply with quote

Very cool - good stuff Mike!
_________________
Yahoo! Messenger ID: alex_t_king
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
GamerZ



Joined: 15 May 2002
Posts: 537
Location: Singapore

PostPosted: Tue Nov 05, 2002 3:57 am    Post subject: Reply with quote

my web server currently down could not ttest it out
and how come my cookie gives me the date 1970?

BTW do u require the function file first or set teh cookie first?
_________________

++ GamerZ.Per.Sg - Complex Simplicity
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
alex_t_king



Joined: 09 Oct 2002
Posts: 194

PostPosted: Tue Nov 05, 2002 4:39 am    Post subject: Reply with quote

It doesn't matter which is first, the cookie has to be set before the HTML is passed to the browser, but the functions just need to be included before they called.

As for 1970 - I'm using unix timestamps when comparing the dates, it defaults to 1970. Not sure where that is coming from though, if there is no cookie set (and it should be set to a recent date) then it shouldn't show the string at all...
_________________
Yahoo! Messenger ID: alex_t_king
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
GamerZ



Joined: 15 May 2002
Posts: 537
Location: Singapore

PostPosted: Tue Nov 05, 2002 7:23 am    Post subject: Reply with quote

okie got eveythign to work except 1 which is the ak_new_comments(), i put that in b2comments.php there is an mysql error where as the ak_new_post is put on index.php no error
_________________

++ GamerZ.Per.Sg - Complex Simplicity
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
alex_t_king



Joined: 09 Oct 2002
Posts: 194

PostPosted: Tue Nov 05, 2002 9:24 am    Post subject: Reply with quote

hmm, yeah - like it says, it expects to be called from within the b2 loop, I haven't tested it elsewhere although it should work assuming the post id is set already or is passed in. I'm guessing that the post id isn't available... what is the mysql error?
_________________
Yahoo! Messenger ID: alex_t_king
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
alex_t_king



Joined: 09 Oct 2002
Posts: 194

PostPosted: Tue Nov 05, 2002 5:28 pm    Post subject: Reply with quote

Another throught - perhaps $tableposts is not defined there? I'm not using b2comments on my site so I haven't played with it at all...
_________________
Yahoo! Messenger ID: alex_t_king
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
MiniSizeIt



Joined: 02 Nov 2002
Posts: 70

PostPosted: Tue Nov 05, 2002 9:31 pm    Post subject: Reply with quote

Yea the comments also gives me a MySQL error.
Back to top
View user's profile Send private message
alex_t_king



Joined: 09 Oct 2002
Posts: 194

PostPosted: Tue Nov 05, 2002 10:05 pm    Post subject: Reply with quote

What is the error and where are you calling the function? are you calling it from within the b2 post loop?
_________________
Yahoo! Messenger ID: alex_t_king
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> Hacks All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group