Jump to content

last post info from subforum


jenuine

Recommended Posts

Hi. First off, thank-you to the makers of this site.

 

My problem involves my forum software, fusionboard, an add-on for php-fusion cms. I'd think it would be a quick solve for a php expert, but they're unresponsive at the fusionboard support forum, so thought I'd try here. My forum: http://meetporthuron.com/forum/index.php

 

There are actually two issues, both to do with the "Last Post" column on the forum index. First, and most important to me, is that when there's a subforum, containing a more recent post than its parent forum, it only shows the last post from the parent forum. I know enough php to serve my purposes, usually, but this one is beyond my knowledge level. I think the problem is somewhere in this bit of code:

$children = array();
	if(dbrows($c_res)){
		while($child_data = dbarray($c_res)){
			array_push($children, $child_data['forum_id']);
			findChildren($child_data['forum_id']);
		}
	}
	if(count($children)){

I put in an echo 'test'; at the end of that and it wasn't displayed in the browser... which should mean that the if(count($children)) isn't finding any children, right? So it's moving on to the else part of the statement?

 

In the func.php file, the findChildren function looks like this:

function findChildren($forum, $childArray = "") {
	if (! isset ( $childArray )) {
		global $children;
	}
	if (! isset ( $children )) {
		$children = array ( );
	}
	$child_res = dbquery ( "select * from " . DB_PREFIX . "fb_forums f
	left join " . DB_PREFIX . "forums f2 on f2.forum_id=f.forum_id
	where " . groupaccess ( "f2.forum_access" ) . " and f.forum_parent='$forum'" );
	if (dbrows ( $child_res )) {
		while ( $child_data = dbarray ( $child_res ) ) {
			array_push ( $children, $child_data ['forum_id'] );
			findChildren ( $child_data ['forum_id'] );
		}
	}
}

 

And finally, here's the complete section of applicable code from the forum index.php file:

		$children = array();
	if(dbrows($c_res)){
		while($child_data = dbarray($c_res)){
			array_push($children, $child_data['forum_id']);
			findChildren($child_data['forum_id']);
		}
	}
	if(count($children)){
		$where = ""; $counter = count($children); $normalWhere = "";
		foreach($children as $child){
			$where .= "t.forum_id='$child' ".($counter > 1 ? "OR " : "");
			$normalWhere .= "forum_id='$child' ".($counter > 1 ? "OR " : "");
			$counter--;
		}
		$posts = $posts + dbcount("(post_id)", DB_POSTS, $normalWhere);
		$threads = $threads + dbcount("(thread_id)", DB_THREADS, $normalWhere);
		$childrenForums = dbquery("select * from ".$db_prefix."threads t
		left join ".$db_prefix."users u on u.user_id=t.thread_lastuser
		left join ".$db_prefix."posts p on p.post_id=t.thread_lastpostid
		where ($where OR t.forum_id='".$data['forum_id']."') 
		order by t.thread_lastpost desc limit 1");
		$childrenData = dbarray($childrenForums);
		if (!dbrows($childrenForums) && !$data['forum_lastpost']) {
			echo $locale['405']."</td>\n";
		} else {
			echo "<b><a href='viewthread.php?thread_id=".$childrenData['thread_id']."' style='text-decoration:underline;'>".trimlink($childrenData['thread_subject'], 30)."</a></b><br />";
			echo "".$locale['406']."<a href='".BASEDIR."profile.php?lookup=".$childrenData['thread_lastuser']."'>".showLabel($childrenData['user_id'], false, "index")."</a><br />
			<div align='right'>".timePassed($childrenData['thread_lastpost'], false)."
			<a href='".FORUM."viewthread.php?thread_id=".$childrenData['thread_id']."&pid=".$childrenData['thread_lastpostid']."#post_".$childrenData['thread_lastpostid']."' title='Go To Last Post'><b>»</b></a></div></td>\n";
		}
	} else {
		if ($data['forum_lastpost'] == 0) {
			echo $locale['405']."</td>\n";
		} else {
			$threadData = dbarray(dbquery("select * from ".$db_prefix."threads t
			left join ".$db_prefix."posts p on p.post_id=t.thread_lastpostid
			left join ".DB_USERS." u on u.user_id=p.post_author
			where t.thread_lastpost='".$data['forum_lastpost']."'"));
			echo "<b><a href='viewthread.php?thread_id=".$threadData['thread_id']."' style='text-decoration:underline;'>".trimlink($threadData['thread_subject'], 30)."</a></b><br />";
			echo "".$locale['406']."<a href='".BASEDIR."profile.php?lookup=".$data['forum_lastuser']."' style='text-decoration:underline;'>".showLabel($threadData['user_id'], false, "index")."</a><br />
			<div align='right'>".timePassed($data['forum_lastpost'], false)."
			<a href='".FORUM."viewthread.php?thread_id=".$threadData['thread_id']."&pid=".$threadData['thread_lastpostid']."#post_".$threadData['thread_lastpostid']."' title='Go To Last Post'><b>»</b></a></div></td>\n";
		}
	}

 

The second issue is that sometimes the topic title and author name go completely missing from the Last Post column, as you can see on my site. This only happens sometimes, and I'm not sure if the problem would be in the same section of code or somewhere else.

 

Any help would be greatly appreciated!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.