Selective last posts (Solved)

Discuss the integratoin of phpbb and Joomla! here.

Moderator: General Support Moderators

Forum rules
Locked
Hobes
Joomla! Intern
Joomla! Intern
Posts: 74
Joined: Sat Oct 22, 2005 9:45 am

Selective last posts (Solved)

Post by Hobes » Fri Mar 10, 2006 11:17 pm

I'm using the module "last posts", and have several forums.

I would like that only the last posts of specific forums to appear there.
I guess the code involved is the following:

Code: Select all

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="<?php echo $moduleclass_sfx; ?>content" align="center">
	<tr>
		<td>
		  <!-- begin topic content -->
      <?
      
      $link = ($component == 1) ? '' : '2';
      
		  $query="SELECT DISTINCT t.topic_id, t.topic_title,  p.post_id, p.post_time, p.poster_id AS poster_id, u.name AS poster
		  FROM phpbb_topics t
		  LEFT JOIN phpbb_posts p ON p.post_id = t.topic_last_post_id
		  LEFT JOIN phpbb_forums f ON t.forum_id = f.forum_id
		  LEFT JOIN #__users u ON p.poster_id = u.id
		  WHERE f.auth_read <= $forum_access 
		  ORDER BY post_time DESC LIMIT 0, $number";
		  //echo $query;
		  $database->setQuery($query);
		  $rows = $database->loadObjectList();
		  
		  //check if there is result
		  if(count($rows) > 0){
		  	
		    for($i=0,$n=count($rows);$i<$n;$i++){
		      $row = &$rows[$i];

		      $topic_title = $row->topic_title;
		      if(strlen($topic_title) > $titlelenght){
					  $topic_title = substr($topic_title, 0, ($titlelenght - 2)) . "...";
		      }

		      $topic_id = $row->topic_id;
		      
		      echo '<font class="cross">+</font> ';
		      echo '<a target="'.$linktarget.'" href="'.sefRelToAbs('index'.$link.'.php?option=com_forum&Itemid='.$menuitem.'&page=viewtopic&t=' . $row->topic_id . '#' . $row->post_id) . '" title="'.$row->topic_title.'">'.$topic_title."</a>";
		      if($display_time == 1){
		        if(!empty($title_time_separator)){
		          echo " " . $title_time_separator;
		        }
		        echo " " . strftime($time_format, $row->topic_time);
		      }
		      if($display_user == 1){
		        if(!empty($time_user_separator)){
		          echo " " . $time_user_separator;
		        }
		        echo ' <a target="'.$linktarget.'" href="'.sefRelToAbs('index'.$link.'.php?option=com_forum&Itemid='.$menuitem.'&page=profile&mode=viewprofile&u=' . $row->poster_id) . '" title="'.$row->poster.'">'.$row->poster."</a>";
		      }
		      echo "<br />\n";
		    }
		  }
		  else {
		     echo '<font class="cross">+</font> <a target="'.$linktarget.'" href="'.sefRelToAbs('index'.$link.'.php?option=com_forum&Itemid='.$menuitem).'">No topics found</a><br>';
		  }
		  ?>                           
			
	</tr>
</table>
Any idea how to get this?

Thank you :)
Last edited by Hobes on Fri Mar 10, 2006 11:52 pm, edited 1 time in total.

Hobes
Joomla! Intern
Joomla! Intern
Posts: 74
Joined: Sat Oct 22, 2005 9:45 am

Re: Selective last posts (SOLVED)

Post by Hobes » Fri Mar 10, 2006 11:51 pm

Ok, found it...
I added: "AND f.forum_id !=7 & 18" in the query, which give now:

Code: Select all

		  $query="SELECT DISTINCT t.topic_id, t.topic_title,  p.post_id, p.post_time, p.poster_id AS poster_id, u.name AS poster
		  FROM phpbb_topics t
		  LEFT JOIN phpbb_posts p ON p.post_id = t.topic_last_post_id
		  LEFT JOIN phpbb_forums f ON t.forum_id = f.forum_id AND f.forum_id !=7 & 18
		  LEFT JOIN #__users u ON p.poster_id = u.id
		  WHERE f.auth_read <= $forum_access 
		  ORDER BY post_time DESC LIMIT 0, $number";
Basically it works :) But not the "&"...
Last edited by Hobes on Mon Apr 24, 2006 9:59 am, edited 1 time in total.

panpaniscus
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Sat Apr 01, 2006 8:26 pm

Re: Selective last posts (Solved)

Post by panpaniscus » Fri Apr 21, 2006 10:56 am

Hi

I have joomla 1.0.8 bridged with phpbb 2.19 standalone

I want install a "last topics" module in my home page.

How can i do this?

How can install the code you posted  like a module?

thanks, Pedro

Hobes
Joomla! Intern
Joomla! Intern
Posts: 74
Joined: Sat Oct 22, 2005 9:45 am

Re: Selective last posts (Solved)

Post by Hobes » Fri Apr 21, 2006 11:40 am

No, you shall add/modify the piece of code related to the request.
In the code below, I've added "AND f.forum_id !=7 AND f.forum_id !=19", so that the last topics of these two forums wouldn't appear in the module.
I'm not an expert. Take this as an experiment; which worked, but nevertheless...

Code: Select all

		  $query="SELECT DISTINCT t.topic_id, t.topic_title,  p.post_id, p.post_time, p.poster_id AS poster_id, u.username AS poster
		  FROM phpbb_topics t
		  LEFT JOIN phpbb_posts p ON p.post_id = t.topic_last_post_id
		  LEFT JOIN phpbb_forums f ON t.forum_id = f.forum_id AND f.forum_id !=7 AND f.forum_id !=19 
		  LEFT JOIN #__users u ON p.poster_id = u.id
		  WHERE f.auth_read <= $forum_access 
		  ORDER BY post_time DESC LIMIT 0, $number";
		  //echo $query;
		  $database->setQuery($query);
		  $rows = $database->loadObjectList();
Hope this helps.

Lucretia
Joomla! Apprentice
Joomla! Apprentice
Posts: 31
Joined: Fri Sep 02, 2005 8:22 am
Location: Hamburg, Germany
Contact:

Re: Selective last posts (Solved)

Post by Lucretia » Mon Apr 24, 2006 9:48 am

hey Hobes,
this is great, thank you - been exactly looking for this! :)

But, how do I manage to show only posts from specific forums in the Community builder User's tab as well?
My php knowledge is pretty poor, so maybe you can help me? I think its the following code which has to be modified:

Code: Select all

$sql = "SELECT COUNT(post_id) as Total, MAX(post_id) as LastPost FROM ".$phpBBtableprefix."posts WHERE forum_id='".$forum->forum_id."'";
...
$sql = "SELECT COUNT(topic_id) as Total FROM ".$phpBBtableprefix."topics WHERE forum_id='".$forum->forum_id."'";
...
$sql = "UPDATE ".$phpBBtableprefix."forums SET forum_posts='".$qtyPosts."', forum_topics='".$qtyTopics."', forum_last_post_id='".$lastpost."' WHERE forum_id='".$forum->forum_id."'";
thanks so much in advance! :)
Last edited by Lucretia on Mon Apr 24, 2006 10:01 am, edited 1 time in total.

mingalababya
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Mon Sep 12, 2005 4:50 am

Re: Selective last posts (Solved)

Post by mingalababya » Wed Apr 26, 2006 12:12 pm

Hobes wrote: I'm using the module "last posts", and have several forums.
Hi Hobes, can you direct me to where you downloaded this 'last post' module from? This may be what I'm looking for. Thanks in advance.

Hobes
Joomla! Intern
Joomla! Intern
Posts: 74
Joined: Sat Oct 22, 2005 9:45 am

Re: Selective last posts (Solved)

Post by Hobes » Wed Apr 26, 2006 12:34 pm

mingalababya wrote:Hi Hobes, can you direct me to where you downloaded this 'last post' module from? This may be what I'm looking for.
I can't remember. But i'm sure you'll find it either here (joomla.org) or on Joomlaya.com.

Lucretia, I know nothing about CommunityBuilder. As I heard some module do not work anymore under CB, I didn't install it.

Thank you :)

mingalababya
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Mon Sep 12, 2005 4:50 am

Re: Selective last posts (Solved)

Post by mingalababya » Wed Apr 26, 2006 3:06 pm

Hobes wrote:
I can't remember. But i'm sure you'll find it either here (joomla.org) or on Joomlaya.com.
Yep, I found it on Joomlaya.com. Thanks very much .. really appreciated it. :)

Lucretia
Joomla! Apprentice
Joomla! Apprentice
Posts: 31
Joined: Fri Sep 02, 2005 8:22 am
Location: Hamburg, Germany
Contact:

Re: Selective last posts (Solved)

Post by Lucretia » Wed Jun 07, 2006 6:16 pm

Hobes wrote:
Lucretia, I know nothing about CommunityBuilder. As I heard some module do not work anymore under CB, I didn't install it.
thats fine - but maybe you or someone else can help me anyway?
As I said, I don't know much (any??) PHP and I just don't know how to write the correct syntax  :-[
I have the code

$sql = "SELECT COUNT(topic_id) as Total FROM ".$phpBBtableprefix."topics WHERE forum_id='".$forum->forum_id."'";

and want to change it so that it gets only the forum ids 4 and 9.
I just have no clue if I have to write

WHERE forum_id='4 AND 9'"

or whatever.
Would be great if someone could tell me  ;)

Lucretia
Joomla! Apprentice
Joomla! Apprentice
Posts: 31
Joined: Fri Sep 02, 2005 8:22 am
Location: Hamburg, Germany
Contact:

Re: Selective last posts (Solved)

Post by Lucretia » Wed Jun 07, 2006 9:11 pm

okay, someone told me now how to do it:

in the file phpbbconnector.php

change

Code: Select all

	function getDisplayTab($tab,$user,$ui) {
		global $database, $table_prefix;
		$this->includephpBBFiles();
		$phpBBtableprefix = $table_prefix;
		$phpBBid = $this->getphpBBid($user);		
		//$phpbbuser= "$user->id";
		$phpbbuser= "$phpBBid";
		$time_format = "%d-%m-%Y";
		global $database,$mosConfig_hits,$mosConfig_vote;
		$return="";
		$query = "SELECT a.topic_id, a.topic_title, a.topic_replies, a.topic_time"
		. "\n FROM ".$phpBBtableprefix."topics AS a"
		. "\n WHERE a.topic_poster=".$phpbbuser.""
		. "\n ORDER BY a.topic_time DESC LIMIT 0, 40"
		;
into

Code: Select all


	function getDisplayTab($tab,$user,$ui) {
		global $database, $table_prefix;
		$this->includephpBBFiles();
		$phpBBtableprefix = $table_prefix;
		$phpBBid = $this->getphpBBid($user);		
		//$phpbbuser= "$user->id";
		$phpbbuser= "$phpBBid";
		$time_format = "%d-%m-%Y";
		global $database,$mosConfig_hits,$mosConfig_vote;
		$return="";
		$query = "SELECT a.topic_id, a.topic_title, a.topic_replies, a.topic_time"
		. "\n FROM ".$phpBBtableprefix."topics AS a"
		. "\n WHERE a.topic_poster=".$phpbbuser." AND a.forum_id!='10'"
		. "\n ORDER BY a.topic_time DESC LIMIT 0, 40"
		;
Insert in forum–id!='10' the id of your forum of which you want the posts NOT to be displayed in the CB tabs (replace the 10 by your id).
Works! :)
Last edited by Lucretia on Wed Jun 07, 2006 9:13 pm, edited 1 time in total.


Locked

Return to “phpbb - Joomla! Integration”