Author |
Message |
doulos Board Member
Joined: 29 Oct 2017
Posts: 4
|
Posted: Sun Oct 29, 2017 12:38 am Post subject: Today's Posts link |
|
|
I am looking to add a link to search for "today's" post similar to vbulletin's "https://forums-somewhere-else.net/search.php?do=getdaily" but have not found a solution. I found something a phpbb3 mod for this but it doesn't work for phpbb2 (at I couldn't get it to work).
Thanks. |
|
Back to top |
|
|
Salvatos Board Member
Joined: 19 Feb 2009
Posts: 449 Location: Québec
|
Posted: Sun Oct 29, 2017 6:36 am Post subject: Re: Today's Posts link |
|
|
This board actually has something similar in the search box though it seems to be going back several days (2 according to the help page, but I see posts from 4 days back). Maybe drathbun could share the code, but if you're familiar enough with PHP you could probably do it yourself by adapting the "since last visit" option around line 184 of search.php:
Code: | if ( $search_id == 'newposts' )
{
if ( $userdata['session_logged_in'] )
{
$sql = "SELECT post_id
FROM " . POSTS_TABLE . "
WHERE post_time >= " . $userdata['user_lastvisit'];
}
else
{
redirect(append_sid("login.$phpEx?redirect=search.$phpEx&search_id=newposts", true));
}
$show_results = 'topics';
$sort_by = 0;
$sort_dir = 'DESC';
} |
Replacing the WHERE with something like:
Code: | WHERE post_time >= ($current_time - (60 * 60 * 24)); |
I don't have time to try it out and find everything you would need to replicate or where to add links to the actual feature, but hopefully this can get you started |
|
Back to top |
|
|
doulos Board Member
Joined: 29 Oct 2017
Posts: 4
|
Posted: Sun Oct 29, 2017 4:17 pm Post subject: Re: Today's Posts link |
|
|
Thanks I will give a go. |
|
Back to top |
|
|
doulos Board Member
Joined: 29 Oct 2017
Posts: 4
|
Posted: Mon Oct 30, 2017 3:14 am Post subject: Re: Today's Posts link |
|
|
Sadly, it did not work. |
|
Back to top |
|
|
drathbun Board Member
Joined: 24 Jul 2008
Posts: 729 Location: Texas
|
Posted: Tue Sep 11, 2018 8:06 pm Post subject: Re: Today's Posts link |
|
|
What is your actual request? Do you want anything that happened in the last 24 hours, or something that specifically happened on the day that you're visiting? The search code is a bit of a mess, honestly, but you can add additional search options as long as you have a good definition of what you want.
For example, as mentioned previously, this forum uses a search token called "recent" which goes back a certain number of minutes. In our case it's a constant called RECENT_POST_THRESHOLD and the code looks like this:
Code: | else if( $search_id == 'recent' )
{
$temptime = time() - RECENT_POST_THRESHOLD;
$sql = 'SELECT post_id
FROM ' . POSTS_TABLE . '
WHERE post_time >= ' . $temptime;
$show_results = 'topics';
$sort_by = 0;
$sort_dir = 'DESC';
}
|
That code goes into the big "if" statement in search.php. There are also language strings.
Code: | 'L_SEARCH_RECENT_TOPICS' => $lang['Search_recent'], |
The URL building code
Code: | 'U_SEARCH_RECENT_TOPICS' => append_sid("search.$phpEx?search_id=recent"), |
My constants go into a file called local_constants.php but these could easily go into the standard constants.php
Code: | define('RECENT_POST_THRESHOLD', 604800); |
For this board, since it's so inactive, the threshold is currently set to seven days.
Getting the URL onto the screen somewhere means a template modification.
But that's basically it, and it's most of what was already posted. If you can post something more descriptive than "it's not working" someone might be able to help further. _________________ phpBBDoctor Blog |
|
Back to top |
|
|
doulos Board Member
Joined: 29 Oct 2017
Posts: 4
|
Posted: Wed Sep 12, 2018 6:30 am Post subject: Re: Today's Posts link |
|
|
I'll take a look when I get a free moment. Thanks. |
|
Back to top |
|
|
Vendethiel Board Member
Joined: 26 Oct 2014
Posts: 251
|
Posted: Wed Sep 12, 2018 8:22 am Post subject: Re: Today's Posts link |
|
|
Yeah, shame that phpBB2 didn't come with rss, to be honest (I've been using the BOB daily digest that's on this board and while it's very useful, there are a few minor things I don't like with it, mostly the fact it sends "empty" emails). _________________ Developer on EzArena, the ADR premod.
Developer on Icy Phoenix, the phpBB hybrid cms.
Developer on IntegraMOD, the full-featured premod.
Help me archive premods on github! (fixed for recent PHPs). |
|
Back to top |
|
|
drathbun Board Member
Joined: 24 Jul 2008
Posts: 729 Location: Texas
|
Posted: Wed Sep 12, 2018 9:00 am Post subject: Re: Today's Posts link |
|
|
I'll take a quick look and see how hard it would be to not send empty emails. On BOB that never was a problem. Here I can see that it would be.
[Edit] Ha, you are the only current digest subscriber. I will need to do some checking to review the code because the digest is written in Perl and I haven't done anything there for a long time... [/Edit] _________________ phpBBDoctor Blog |
|
Back to top |
|
|
Vendethiel Board Member
Joined: 26 Oct 2014
Posts: 251
|
Posted: Thu Sep 13, 2018 11:22 am Post subject: Re: Today's Posts link |
|
|
Feel free to page me, I'm a huge Perl fan (though depending on how old the Perl code is... hehe). _________________ Developer on EzArena, the ADR premod.
Developer on Icy Phoenix, the phpBB hybrid cms.
Developer on IntegraMOD, the full-featured premod.
Help me archive premods on github! (fixed for recent PHPs). |
|
Back to top |
|
|
drathbun Board Member
Joined: 24 Jul 2008
Posts: 729 Location: Texas
|
Posted: Thu Sep 13, 2018 11:02 pm Post subject: Re: Today's Posts link |
|
|
The Perl code is from 2002, when my other board "BOB" was launched. Going off-topic here, but...
I had planned to potentially delivery hundreds or even thousands of digest emails. The phpBB board we were starting was replacing a mailing list, so I wasn't sure how quickly people would take to the new format. I needed to come up with a good design that was efficient. Here's what I did.
Part one of the code selects the min / max post id for the last 24 hours and saves them. The idea is I need a consistent post window even if new posts come in while I'm processing the digest. Then I cycle through every forum and generate an output file called forum_id.txt and forum_id.html which contains the content for that forum that fits the post range. I loop through the forum table once to do that. The result is a bunch of text files that contain the digest information for that forum for that day.
Part two cycles through the users that have at least one subscription. I build the email header in the desired format (html or text) first, then loop through their selected list of forums. For each forum_id I slurp in the content of the html/txt file I created in part one in append mode. At the end of that user, I append the standard footer and then send the email.
So I loop through forums once, and loop through users once, rather than looping through the forums every time I pick up a new user. I can build and send hundreds of emails really fast, with only two main queries. It has been working well.
Except on boards that aren't very active, in which case it sends a bunch of "no posts for this forum" messages. I assumed that's what you meant by empty email? _________________ phpBBDoctor Blog |
|
Back to top |
|
|
Vendethiel Board Member
Joined: 26 Oct 2014
Posts: 251
|
Posted: Mon Sep 17, 2018 5:04 am Post subject: Re: Today's Posts link |
|
|
Yes, that's exactly what I mean. _________________ Developer on EzArena, the ADR premod.
Developer on Icy Phoenix, the phpBB hybrid cms.
Developer on IntegraMOD, the full-featured premod.
Help me archive premods on github! (fixed for recent PHPs). |
|
Back to top |
|
|
drathbun Board Member
Joined: 24 Jul 2008
Posts: 729 Location: Texas
|
Posted: Tue Sep 18, 2018 1:01 am Post subject: Re: Today's Posts link |
|
|
So in that case you would prefer to get nothing instead of an email that tells you nothing was happening? _________________ phpBBDoctor Blog |
|
Back to top |
|
|
Vendethiel Board Member
Joined: 26 Oct 2014
Posts: 251
|
Posted: Wed Sep 19, 2018 6:17 am Post subject: Re: Today's Posts link |
|
|
Indeed. No notification if nothing has to be notified. _________________ Developer on EzArena, the ADR premod.
Developer on Icy Phoenix, the phpBB hybrid cms.
Developer on IntegraMOD, the full-featured premod.
Help me archive premods on github! (fixed for recent PHPs). |
|
Back to top |
|
|
|