{REQUEST} - Topics Anywhere for phpBB 3.x.

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Anti-Spam Guide
hunainraza
Registered User
Posts: 12
Joined: Sat Jul 18, 2009 8:29 am
Contact:

Re: [REQUEST] Recent Posts on Home Page

Post by hunainraza » Sat Aug 22, 2009 7:46 am

starry-eyed wrote:Here is a script on recent posts/topics that is working great on phpBB2 but its SQL command no longer works on phpBB3. Anyone out there check the SQL command and make it work on phpBB3?

Code: Select all

<? 
/**
* Mod Title:   Latest posts/topics
* Mod Version: phpBB 2.0
* Author:      Pegas (pegas@ami.cz) (originally made by ?, previous version by LiLCoolboy (M@urice Cheung))
* Description: Shows latest posts or topics on any page, 2 optional parameters
* Release:     v3.0, 27.01.2003
***
* DeMo:                http://kocky-online.cz (Czech language) 
* Installation Level:  Easy 
* Installation Time:   5 minutes 
* Files To Edit:       0 
* Included Files:      (if necessary) 
***
* Installation Notes:
* Put this code into new file, set $serverPath and $urlPath, 
* upload this file onto server and include into your page and you are done!
*   -- OR --
* Put this code into your page, set $serverPath and $urlPath, 
* and you are done!
***
* Parameters:
* There are 2 optional parameters when calling this code as standalone file via include!
* type - whether to show topics or posts
*   type=posts  - posts [default when missing]
*   type=topics - topics
* count - how much posts/topics show
*   count=# [default is 3]
***
* Examples (assume that your file with this code is hilites.php):
* hilites.php?type=topics&count=5
*  - shows latest 5 topics
* hilites.php?type=topics
*  - shows latest 3 topics
* hilites.php
*  - shows latest 3 posts
***
* Revision:
* v1.0 
*  author: ?
* v2.0
*  author: LiLCoolboy (M@urice Cheung) 
*  - not working without significant changes, mistypes
* v3.0
*  author: Petr Gasparik
*  + added parameters when called as standalone file
*  + posts/topics selection corrected
*  + corrected mistypes
*/
$urlPath = "ABSOLUTE_PATH_OF_YOUR_FORUM";	//example: if your forum URL looks like http://kocky-online.cz/forum, this should be "/forum"
$serverPath = "PATH_TO/config.php";			//example: when this file is in URL path /forum/mod, this should be ../config.php
if(empty($count))
	$count = "3";									//default value of how many posts/topics to show
if(empty($type))
	$type = "posts";		//default value of whether to show 'posts' or 'topics' 
$titleLimit = 30;			//this is max.length of 'title' of topic/post
$moreLimit = 20;			//this is max.length of 'more' (used in posts)

//-----------------[ DO NOT EDIT BELOW HERE ]------------------------- 
include_once("$serverPath"); 
$db = @mysql_connect("$dbhost", "$dbuser", "$dbpasswd") or die("here we die at connection"); 
@mysql_select_db("$dbname",$db) or die("here we die"); 

if($type == "posts") 
{
	$prefix = 'p';
   $sql = "SELECT x.post_subject as title, p.post_id as id, f.forum_id, t.topic_title as more "
   		."FROM ${table_prefix}topics t, ${table_prefix}forums f, ${table_prefix}posts p, ${table_prefix}posts_text x "
   		."WHERE t.topic_id = p.topic_id AND f.forum_id = t.forum_id AND p.post_id = x.post_id "
   		."ORDER BY p.post_id DESC "
   		."LIMIT $count"; 
}
else 
{
	$prefix = 't';
   $sql = "SELECT t.topic_title as title, t.topic_id as id, f.forum_id, '' as more "
   		."FROM ${table_prefix}topics t, ${table_prefix}forums f "
   		."WHERE f.forum_id = t.forum_id "
   		."ORDER BY topic_time DESC "
   		."LIMIT $count"; 
}

//echo $sql;

if($r = mysql_query($sql, $db)) { 
	while($m = mysql_fetch_array($r)) { 
		$j = stripslashes($m[title]); 
		$k = substr($j, 0, $titleLimit) . "..."; 
		if(!empty($m[more]))
			$m[more] = '('.substr($m[more], 0, $moreLimit) . '...)'; 
		if ($type == 'posts') {
			$anchor = '#'.$m[id];
		}
		//-------------------[ THIS IS ONLY LINE YOU COULD CHANGE ]--------------------------
		echo "<a title=\"$m[title]\" href=\"$urlPath/viewtopic.php?${prefix}=$m[id]&sid=$m[forum_id]${anchor}\">$k</a> $m[more]<br>"; 
	} 
} 
/
//-------------------[ DO NOT EDIT UP HERE ]--------------------------
?>

where he include this file?

gilababeng
Registered User
Posts: 2
Joined: Mon Sep 14, 2009 7:01 am

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by gilababeng » Mon Sep 14, 2009 7:17 am

Hi,
i use ameeck's script - and it worked.
<?php
/**
* newest_posts - raw dump of newest posts from forum
*
* @copyright (c) 2008 ameeck / Vojtech Vondra - phpBB.cz
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
define('IN_PHPBB', true);
$phpEx = substr(strrchr(__FILE__, '.'), 1);
$phpbb_root_path = '/home/site/public_html/forums/';

include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

require($phpbb_root_path .'includes/functions_user.php');

// Number of posts and grabbing permissions
$topic_limit = request_var('topic_limit', 8);

// forum_id to grab topics from (must be a valid forum_id integer)

$forums = array_unique(array_keys($auth->acl_getf('f_read', true)));

// Initial var setup
$forum_id = request_var('f', 0);
$topic_id = request_var('t', 0);
$forum_sql = empty($forum_id) ? '' : (" AND f.forum_id = '$forum_id'");
$topic_sql = empty($topic_id) ? '' : (" AND p.topic_id = t.topic_id AND t.topic_id = '$topic_id'");

// Select the last topics to which we have permissions
//$sql = 'SELECT p.post_id, p.topic_id, p.forum_id, p.post_subject, p.post_text, p.post_time, u.username
$sql = 'SELECT p.post_id, p.topic_id, p.forum_id, p.post_subject, p.post_time, u.username
FROM '. FORUMS_TABLE .' f,'.TOPICS_TABLE.' t, '.POSTS_TABLE.' p,'.USERS_TABLE.' u
WHERE t.forum_id = f.forum_id
AND t.topic_status != 1
AND u.user_id = p.poster_id' . $forum_sql . $topic_sql . (empty($topic_sql) ? ' AND p.post_id = t.topic_last_post_id ' : '') . '
ORDER BY ' . (empty($topic_sql) ? 't.topic_last_post_time DESC' : 'p.post_time DESC') . '
LIMIT 0,' . $topic_limit;
$result = $db->sql_query($sql);

// Proper header since output not buffered
header('Content-Type: text/html; charset=utf-8');

// Now let's output the content border: 1px solid #734518;background-color:#F5F0D0;
//echo '<div style=""><strong></strong>';
//echo '<ul style="margin-left:0px;list-style-type:none;">';
while ($row = $db->sql_fetchrow($result)) {
$url = generate_board_url() . "/viewtopic.{$phpEx}?f={$row['forum_id']}&t={$row['topic_id']}&p={$row['post_id']}#p{$row['post_id']}";
$count = count(@explode($$row['post_subject']," "));
$count = strlen($row['post_subject']) - ( $count - 1 );
$subject = strlen($row['post_subject']) > 27? substr($row['post_subject'],0,24)."...": $row['post_subject'];
echo '<div style="padding-bottom:5px;"><a target="_parent" title="'.$row['post_subject'].'" href="' . $url . '">' . $subject . '</a> - ' . $row['username'] . ' : ' . date("D m/d/y, h:ia",$row['post_time']) . ' </div>';
//echo '<li>' . $row['post_text'] . '</li><br><br>';
//echo '<li style="padding-bottom:4px;text-align:right;"> </li>';
}
//echo '</ul></div>';
//echo '</ul>';
I just removed this line to get it worked , ( for those who got errors bout headers warning bla2 ):

Code: Select all

// Proper header since output not buffered
header('Content-Type: text/html; charset=utf-8');
To Ameeck,
I have simple question:
1. How can I make last poster name clickable ? ( click and I can view the profile id )
2. I've make the test, u can see here. It really worked but all the posting seem to be appeared. I just want the topic, and some posting and if the posting too long it will be shortened and can click MORE for the full view.
3. I've figured out that I exactly want make the same as recent forum post's knowledgeofbonsai.org . He integrated using wordpress's rsswidget and it seems to be cool. Please teach me how can I do like that. =)
I will give full credit to those who want to help me ;)

Thanks,
gilababeng

gilababeng
Registered User
Posts: 2
Joined: Mon Sep 14, 2009 7:01 am

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by gilababeng » Mon Sep 14, 2009 8:59 am

TheSa|nt wrote:FYI, I think I got it!


What I did was change
$phpbb_root_path = './';

to
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';


and it appears to be working. So if anyone else has that problem....there's the solution ;)
I've tried. And that was not the exact solution.

1. add this on the top line (after <?php):
<?php

Code: Select all

ob_start();
	session_start();
2.. make sure it is UTF-8 ( if coded in Dreamweaver pls resave in notepad in ANSI or UTF-8, I suggest notepad++ for great result)

3. make sure no empty space <?php and ?>

p/s: I dont know much, just trying to help. =p

A. de Kruijf
Registered User
Posts: 4
Joined: Sun Dec 27, 2009 11:17 am

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by A. de Kruijf » Sun Dec 27, 2009 11:20 am

Hello,

I'm using the code from IoanFilipov and it works great!
But i still can't manage to exclude the moderator forum in the iframe.

Can anyone tell me how i can exclude the moderator forum and the topics in this forum?

Thanks already.

User avatar
sbonnand
Registered User
Posts: 1
Joined: Tue Jan 05, 2010 7:22 am

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by sbonnand » Tue Jan 05, 2010 7:30 am

hello !

Thanks to johnnyvang and IoanFilipov for the code, it works very well.

In order to exclude or include forums, you only need to change a little the SQL Request

this is the code I used to only show messages from the forum #15

Code: Select all

$latest_topics = "SELECT * FROM $table_prefix".topics." WHERE topic_approved = '1' AND forum_id=15 ORDER BY topic_last_post_time DESC LIMIT 0,$latest";
But if you want all the forum except the #15 :

Code: Select all

$latest_topics = "SELECT * FROM $table_prefix".topics." WHERE topic_approved = '1' AND forum_id<>15 ORDER BY topic_last_post_time DESC LIMIT 0,$latest";
Hope this help !

A. de Kruijf
Registered User
Posts: 4
Joined: Sun Dec 27, 2009 11:17 am

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by A. de Kruijf » Tue Jan 05, 2010 8:24 pm

Thanks for your answer.

I tryed it, but i still can get it to work?

Were do i put this code on the page ? Does it make any different?

Thans again.

Captain Pervert
Registered User
Posts: 48
Joined: Mon May 26, 2003 3:24 pm
Location: Netherlands
Contact:

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by Captain Pervert » Mon Jan 11, 2010 9:09 am

How do I stop the script from showing threads from hidden forums (when not logged in)
When a user has permission for the hidden forum, the threads are shown.

How to do that?

Besides, I'd rather have an official Phpbb mod for this. I had been using TopicsAnywhere for phpbb2 for years, it amazes me that no one made something like that for phpbb3. It is an excellent script.

Any chance for an official mod?????

buksida
Registered User
Posts: 308
Joined: Thu Feb 04, 2010 9:11 am

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by buksida » Thu Feb 04, 2010 1:30 pm

I've followed this thread since its beginning almost 3 years ago and it seems that a real Topics Anywhere MOD for phpBB3 still eludes us. I have put off upgrading my main board until an official MOD is available but I can't wait for much longer, I used Topics Anywhere to syndicate my posts onto other related sites and draw traffic into the forum - it is essential to the forums growth and I'm baffled as to why the existing script hasn't been modified to work on phpBB3 as it worked so well.

I have upgraded one of my smaller boards and used the Ioan Filipov code supplied on page 2 or 3 of this thread. This code works fine, you can apply css, include or exclude specific forums, manage what is displayed, and run it on HTML pages (even on other websites) in an IFrame. It may be a security risk (as stated by one of the moderators) but its either that or lose a lot of traffic or stick with phpBB2 or ......... wait for a real Topics Anywhere MOD which could be a long time!

In answer to the above using

Code: Select all

AND forum_id<>15
to exclude and

Code: Select all

AND forum_id=15
to include works, you can also do it with multiple forums.

A. de Kruijf
Registered User
Posts: 4
Joined: Sun Dec 27, 2009 11:17 am

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by A. de Kruijf » Thu Feb 04, 2010 6:14 pm

Thanks for the update.
But where do i place this code?

buksida
Registered User
Posts: 308
Joined: Thu Feb 04, 2010 9:11 am

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by buksida » Fri Feb 05, 2010 6:48 am

In this line:

Code: Select all

$query="select * from $table".topics."  WHERE topic_approved = '1' AND forum_id<>5 order by topic_last_post_time desc limit 0,$laforums";
That will exclude forum 5

Code: Select all

$query="select * from $table".topics."  WHERE topic_approved = '1' AND forum_id=5 order by topic_last_post_time desc limit 0,$laforums";
That will display only forum 5

A. de Kruijf
Registered User
Posts: 4
Joined: Sun Dec 27, 2009 11:17 am

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by A. de Kruijf » Fri Feb 05, 2010 5:32 pm

It still won't work? When i put in forum id 57 it's still displaying this forum.
Strange.

maybe i put the code on te wrong place in the page? Is that possible?

buksida
Registered User
Posts: 308
Joined: Thu Feb 04, 2010 9:11 am

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by buksida » Sat Feb 06, 2010 1:42 am

Are you sure you're using the Filipov code from here:
http://phpbb.com/community/viewtopic.ph ... 4&start=30

It works fine for me.

I do have a couple of issues with that code though namely,

1) The time/date stamp is a few hours out
2) The jump to last post shows only the posts on that page without the ability to go to previous pages
3) It does not always instantly update (though this maybe due to browser/ISP caching somewhere)

I may also try the other code suggested here if I can't resolve these issues.

patrick181
Registered User
Posts: 12
Joined: Thu Sep 17, 2009 7:53 pm

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by patrick181 » Thu Feb 11, 2010 5:16 pm

Im' running the Filipov code. It works but I cannnot get CSS to control the text, its 12 point Times :( . Any Ideas?

buksida
Registered User
Posts: 308
Joined: Thu Feb 04, 2010 9:11 am

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by buksida » Tue Feb 16, 2010 8:53 am

patrick181 wrote:Im' running the Filipov code. It works but I cannnot get CSS to control the text, its 12 point Times :( . Any Ideas?
Just put the link to your css file at the top of the lasttopic.php file (or whatever you've called it) and close it at the bottom:

Code: Select all

<link type="text/css" rel="Stylesheet" href="http://www.yourdomain.com/stylesheet.css" />
<span class="mystyle">
<?
        /*** phpBB3 - Last Active Topics System ***/

        //Author: Ioan Filipov .......

User avatar
murdock
Registered User
Posts: 20
Joined: Wed Nov 19, 2003 1:47 am
Location: New Jersey
Contact:

Re: {REQUEST} - Topics Anywhere for phpBB 3.x.

Post by murdock » Sun Feb 21, 2010 4:11 am

scandal20 wrote:Is there still much of a demand for a clone of Topics Anywhere for phpBB 3.0.x? Seems like some people have found solutions, but others are still left in the dark because they need this functionality for .html pages. I've been looking for a project to work on in my free time so if there's enough interest I might be willing to try to port Topics Anywhere from phpBB2.
This was my exact problem. I need the JavaScript functionality to display the topics, poster, date, etc... on an ASP page. I don't like inline frames. I held off from 3.x for a while, but in April 2008, I converted over. I figured, how hard could it be to just change the query to use the new database structure. What did I know...NOTHING! Everything changed, from the ground up, and I had no clue what I was doing.

But I didn't let that stop me. Nooo. After about 14 days, I had successfully converted Topics_Anywhere 1.11.0 to phpBB3. Well...not completely. I was able to convert it so that it would at least function exactly like it used to under the old version, except for the part of the page that creates the link.(and that's the part I need now. :( ) And...I had to hard code some of the paths. SO...this wasn't going to help anyone. I thought about trying to document the changes so people could try their hands at modifying their own T_A, but I just never got around to it.

Oh no...I think there might have been other changes that I can't even remember now....so I'm not even sure my code would help anyone.

I tried to keep the modifications inline, so that you could actually compare my T_A file to the original T_A file, and see what I changed. Hey...If you want, I'll do that. Just give me a day or so to work on it. Wow...If I am reading this correctly, there less than 40 lines of code with changes. Let me see if I can dump that out right now really quick. Again...I don't know how much use this will be to any of you, but if you've got nothing now, you won't be any worse off.

Locked

Return to “[3.0.x] MOD Requests”