MyBB Community Forums

Full Version: IMP Forums
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey gang,

So I finally got the perfect plugin to modify thanks to Destroy666 and also thanks to Dragon, they have been an awesome help.


The plugin is Imp Forums.
which looks like this

[Image: impfofrums.png]



here is what I need to do

I have three categories - pid 47,48,35

aka - music, resources and classifieds



here are the tables of the plugin:

Table frame:

	<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
		<thead>
		<tr>
		<td class="thead" colspan="{$clspn}">
		<div class="expcolimage"><img src="{$theme['imgdir']}/collapse{$collapsedimg['impforums']}.gif" id="impforums_img" class="expander" alt="[-]" title="[-]" /></div>
		<div><strong>{$lang->impforums_title}</strong><br /><div class="smalltext">{$lang->impforums_desc}</div></div>
		</td>
		</tr>
		</thead>
		<tbody style="{$collapsed['impforums_e']}" id="impforums_e">
		<tr>
		<td class="tcat" align="left"><span class="smalltext"><strong>{$lang->impforums_name}</strong></span></td>
		<td class="tcat" align="center" width="100"><span class="smalltext"><strong>{$lang->impforums_threads}</strong></span></td>
		{$impforums_lastpostcat}
		</tr>
		{$impforums_entry}
		</tbody>
	</table>
	<br />



Table rows:

<tr>
		<td class="{$bgcolor}" valign="top" align="left" style="white-space: nowrap"><a href="forumdisplay.php?fid={$impforum['fid']}"><strong>{$impforum['name']}</strong></a></td>
		<td class="{$bgcolor}" valign="top" align="center" style="white-space: nowrap">{$impforum['threads']}</td>
		{$impforums_lastpost}
	</tr>


I just simply want to change the table layout to 3 columns, not 3 rows.

3 table columns like this:
[Image: impfofrums2.png]


here is the plugin's php
<?php

/*
*
*   Imp Forums
*   A Plugin for MyBB to display the count of threads under a certain category / forum in Index. 
*   effone @ demonate.com
*
*
*/

// Disallow direct access to this file
if(!defined("IN_MYBB")){
	die("Don't be smart, use links in page.");
}

// Basic Informations about the plugin
function impforums_info(){
	return array(
		'name'			=> 'Imp Forums',
		'description'	=> 'Display the count of threads under a certain category / forum in Index.',
		'website'		=> 'http://demonate.com',
		'author'		=> 'effone',
		'authorsite'	=> 'http://effone.in',
		'version'		=> '0.1',
		'guid' 			=> '2c099a3950a42f5b1d66c28289b8f028',
		'compatibility' => '18*'
	);
}

// Hooks :o
$plugins->add_hook('index_end', 'impforums_builder');

function impforums_builder(){

	global $mybb, $theme, $fcache, $result_array, $templates, $collapsed, $collapsedimg, $lang, $impforums;

	// Set to work when activated from settings as well as any forum is set to fetch data
	if ($mybb->settings['impforums_active'] && !empty($mybb->settings['impforums_forums'])) {
		// Create the blank result array
		$result_array = array();

		$target_forum_array = explode(',', $mybb->settings['impforums_forums']);

		foreach ($target_forum_array as $infid) {
			// Check In to omit non-integer inputs
			$infid = intval($infid);
			if(!empty($infid)){
				// First target the parent forums
				$target_forum = build_forumbits($infid);

				if(is_null($target_forum['counters']['threads'])) { // Its not a parent
					impforums_recurse(&$fcache, &$infid);
				} else { // Its a parent, yay :D
					$forum_detail = get_forum($infid);

			    	$forum_value['fid'] = $forum_detail['fid'];
			    	$forum_value['name'] = $forum_detail['name'];
			    	$forum_value['threads'] = $target_forum['counters']['threads'];
			    	$forum_value['lastposttid'] = $target_forum['lastpost']['lastposttid'];
			    	$forum_value['lastposter'] = $target_forum['lastpost']['lastposter'];
			    	$forum_value['lastposteruid'] = $target_forum['lastpost']['lastposteruid'];
			    	$forum_value['lastpostsubject'] = $target_forum['lastpost']['lastpostsubject'];

		    		$result_array[] = $forum_value;
			    }
			}		
		}

		// We have made our result array. Lets templatize it.

		$bgcolor = alt_trow(true); // Reset the trow colors
		$clspn = $mybb->settings['impforums_lastact'] ? 3 : 2;

		$lang->load("impforums");

		if(count($result_array) > 0){
			foreach ($result_array as $impforum) {

				// Trimout extra characters in subject, if set
				$char = intval($mybb->settings['impforums_subtrim']);
				$impforum['lastpostsubject'] = (!empty($char) && strlen($impforum['lastpostsubject']) > $char) ? substr($impforum['lastpostsubject'],0,$char).'...' : $impforum['lastpostsubject'];
				
				if($mybb->settings['impforums_lastact']){
					$last_poster = $mybb->settings['impforums_lastposter'] ? '<span class="smalltext"> ('.$lang->impforums_by.' '.build_profile_link($impforum['lastposter'], $impforum['lastposteruid']).')</span>' : '';
					$impforum['lastactive'] = empty($impforum['lastpostsubject']) ? '--' : '<a href="showthread.php?tid='.$impforum['lastposttid'].'&action=lastpost"><strong>'.$impforum['lastpostsubject'].'</strong></a>'.$last_poster;
				
					eval("\$impforums_lastpostcat = \"".$templates->get("impforums_lastpostcat")."\";");
					eval("\$impforums_lastpost = \"".$templates->get("impforums_lastpost")."\";");
				}

				eval("\$impforums_entry .= \"".$templates->get("impforums_tablerow")."\";");

				$bgcolor = alt_trow();
			}
		} else {
			eval("\$impforums_entry .= \"".$templates->get("impforums_nodata")."\";");
		}
		eval("\$impforums = \"".$templates->get("impforums_tableframe")."\";");
	}
}

function impforums_recurse($inarray, $fid) {
	global $mybb, $result_array;

    foreach ($inarray as $inval) {
        if (is_null($inval['fid'])) {
            $result = impforums_recurse($inval, $fid);
        } else if ($inval['fid'] == $fid){
            $result = $inval;
        }
    }
    // Escape null arrays, decide whether forums with no threads to include and insert valid data chunk in result array
    if($result['name'] && ($result['threads'] || $mybb->settings['impforums_shownull'])) {
	    $result_array[] = $result;
	}
}

// Plugin activation routine
function impforums_activate(){
	global $db, $mybb;
	
	//	Create New Global Templates
	$new_template = array();
	
	$new_template['impforums_tableframe'] = '
	<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
		<thead>
		<tr>
		<td class="thead" colspan="{$clspn}">
		<div class="expcolimage"><img src="{$theme[\'imgdir\']}/collapse{$collapsedimg[\'impforums\']}.gif" id="impforums_img" class="expander" alt="[-]" title="[-]" /></div>
		<div><strong>{$lang->impforums_title}</strong><br /><div class="smalltext">{$lang->impforums_desc}</div></div>
		</td>
		</tr>
		</thead>
		<tbody style="{$collapsed[\'impforums_e\']}" id="impforums_e">
		<tr>
		<td class="tcat" align="left"><span class="smalltext"><strong>{$lang->impforums_name}</strong></span></td>
		<td class="tcat" align="center" width="100"><span class="smalltext"><strong>{$lang->impforums_threads}</strong></span></td>
		{$impforums_lastpostcat}
		</tr>
		{$impforums_entry}
		</tbody>
	</table>
	<br />';

	$new_template['impforums_tablerow'] = '
	<tr>
		<td class="{$bgcolor}" valign="top" align="left" style="white-space: nowrap"><a href="forumdisplay.php?fid={$impforum[\'fid\']}"><strong>{$impforum[\'name\']}</strong></a></td>
		<td class="{$bgcolor}" valign="top" align="center" style="white-space: nowrap">{$impforum[\'threads\']}</td>
		{$impforums_lastpost}
	</tr>';
				
	$new_template['impforums_lastpostcat'] = '<td class="tcat" align="right"><span class="smalltext"><strong>{$lang->impforums_lastactive}</strong></span></td>';

	$new_template['impforums_lastpost'] = '<td class="{$bgcolor}" valign="top" align="right" style="white-space: nowrap">{$impforum[\'lastactive\']}</td>';
	
	$new_template['impforums_nodata'] = '<td class="{$bgcolor}" colspan="{$clspn}" valign="top" align="center" style="white-space: nowrap">{$lang->impforums_nodata}</td>';

	foreach($new_template as $title => $template)
	{
		$new_template = array('title' => $db->escape_string($title), 'template' => $db->escape_string($template), 'sid' => '-1', 'version' => '1612', 'dateline' => TIME_NOW);
		$db->insert_query('templates', $new_template);
	}

	// Insert the variable in templates.
	require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
	find_replace_templatesets("index", "#".preg_quote("{\$boardstats}")."#i", "{\$impforums}\r\n{\$boardstats}");
	
	// Build the ACP Settings for Imp Forums
	$impforums_group = array(
		"name"			=> "impforums",
		"title"			=> "Imp Forums",
		"description"	=> "Display the count of threads under a certain category / forum in Index.",
		"disporder"		=> "3",
		"isdefault"		=> "0"
	);	
	$db->insert_query("settinggroups", $impforums_group);
	$gid = $db->insert_id();
	
	$impforums[] = array(
		"name"			=> 'impforums_active',
		"title"			=> 'Activate Imp Forums?',
		"description"	=> 'Switch to activate or deactivate the plugin.',
		"optionscode" 	=> "onoff",
		"value"			=> '1',
		"disporder"		=> '1',
		"gid"			=> intval($gid),
	);	
	
	$impforums[] = array(
		"name"			=> 'impforums_forums',
		"title"			=> 'Forums to display the status of ...',
		"description"	=> 'Set the forum ids (fid) of which you want to display the status, separated by comma (,).',
		"optionscode" 	=> "text",
		"value"			=> '1,2',
		"disporder"		=> '2',
		"gid"			=> intval($gid),
	);

	$impforums[] = array(
		"name"			=> 'impforums_shownull',
		"title"			=> 'Display status of empty forums?',
		"description"	=> 'Set it off if you do not want to display the status if defined forum is empty',
		"optionscode" 	=> "onoff",
		"value"			=> '0',
		"disporder"		=> '3',
		"gid"			=> intval($gid),
	);

	$impforums[] = array(
		"name"			=> 'impforums_lastact',
		"title"			=> 'Show last active',
		"description"	=> 'Set if last active thread of the forum to show or not.',
		"optionscode" 	=> "onoff",
		"value"			=> '1',
		"disporder"		=> '4',
		"gid"			=> intval($gid),
	);

	$impforums[] = array(
		"name"			=> 'impforums_subtrim',
		"title"			=> 'Trim last active thread subject',
		"description"	=> 'Set max characters for last active thread subject to preserve space and overflow. Set 0 (zero) to disable trimming.',
		"optionscode" 	=> "text",
		"value"			=> '25',
		"disporder"		=> '5',
		"gid"			=> intval($gid),
	);

	$impforums[] = array(
		"name"			=> 'impforums_lastposter',
		"title"			=> 'Show last poster',
		"description"	=> 'Display the name of last poster beside last active thread title.',
		"optionscode" 	=> "onoff",
		"value"			=> '1',
		"disporder"		=> '6',
		"gid"			=> intval($gid),
	);

	foreach($impforums as $tc_opts)
	{
		$db->insert_query("settings", $tc_opts);
	}
	
	rebuild_settings();
 }

// Plugin deactivation routine
function impforums_deactivate(){
	global $db, $mybb;
    require MYBB_ROOT.'/inc/adminfunctions_templates.php';

	// Delete created templates
	$delete_templates = array('impforums_tableframe', 'impforums_tablerow', 'impforums_lastpostcat', 'impforums_lastpost', 'impforums_nodata');
	foreach($delete_templates as $template)	{ $db->delete_query('templates', "title = '{$template}'"); }

	// Remove variable
	find_replace_templatesets("index", "#".preg_quote("\r\n{\$impforums}")."#i", "", 0);
	
	// Delete Settings
	$db->delete_query("settings", "name IN ('impforums_active', 'impforums_forums', 'impforums_shownull', 'impforums_lastact', 'impforums_subtrim', 'impforums_lastposter')");
	$db->delete_query("settinggroups", "name='impforums'");
	
	rebuild_settings();	
}

?>



Can someone please help me modify the plugin's tables above to be 3 columns instead of three rows?
p.s or is there a way to call each pid count seperatly?

something like {$impfoums =[counter] pid48} to show the count?


I've been working on this little project for a while, so any help would be immensely appreciated so much.
Thats'not that difficult, you'll have to move the <tr> and </tr> tag from table row to the table frame.

Table frame:
	<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
		<thead>
		<tr>
		<td class="thead" colspan="{$clspn}">
		<div class="expcolimage"><img src="{$theme['imgdir']}/collapse{$collapsedimg['impforums']}.gif" id="impforums_img" class="expander" alt="[-]" title="[-]" /></div>
		<div><strong>{$lang->impforums_title}</strong><br /><div class="smalltext">{$lang->impforums_desc}</div></div>
		</td>
		</tr>
		</thead>
		<tbody style="{$collapsed['impforums_e']}" id="impforums_e">
		<tr>
		<td class="tcat" align="left"><span class="smalltext"><strong>{$lang->impforums_name}</strong></span></td>
		<td class="tcat" align="center" width="100"><span class="smalltext"><strong>{$lang->impforums_threads}</strong></span></td>
		{$impforums_lastpostcat}
		</tr>
		<tr>{$impforums_entry}</tr>
		</tbody>
	</table>
	<br />



Table rows:
		<td class="{$bgcolor}" valign="top" align="left" style="white-space: nowrap"><a href="forumdisplay.php?fid={$impforum['fid']}"><strong>{$impforum['name']}</strong></a></td>
		<td class="{$bgcolor}" valign="top" align="center" style="white-space: nowrap">{$impforum['threads']}</td>
		{$impforums_lastpost}
	

EDIT:
As I was thinking about it, this won't get you exactly where you want. But it's a good direction.
Just remember: a <tr> gives you a new row, a <td> a new cell.
(2014-11-12, 05:08 AM)fonta Wrote: [ -> ]Thats'not that difficult, you'll have to move the <tr> and </tr> tag from table row to the table frame.

Table frame:


 <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
 <thead>
 <tr>
 <td class="thead" colspan="{$clspn}">
 <div class="expcolimage"><img src="{$theme['imgdir']}/collapse{$collapsedimg['impforums']}.gif" id="impforums_img" class="expander" alt="[-]" title="[-]" /></div>
 <div><strong>{$lang->impforums_title}</strong><br /><div class="smalltext">{$lang->impforums_desc}</div></div>
 </td>
 </tr>
 </thead>
 <tbody style="{$collapsed['impforums_e']}" id="impforums_e">
 <tr>
 <td class="tcat" align="left"><span class="smalltext"><strong>{$lang->impforums_name}</strong></span></td>
 <td class="tcat" align="center" width="100"><span class="smalltext"><strong>{$lang->impforums_threads}</strong></span></td>
 {$impforums_lastpostcat}
 </tr>
 <tr>{$impforums_entry}</tr>
 </tbody>
 </table>
 <br />



Table rows:


 <td class="{$bgcolor}" valign="top" align="left" style="white-space: nowrap"><a href="forumdisplay.php?fid={$impforum['fid']}"><strong>{$impforum['name']}</strong></a></td>
 <td class="{$bgcolor}" valign="top" align="center" style="white-space: nowrap">{$impforum['threads']}</td>
 {$impforums_lastpost}
 

EDIT:
As I was thinking about it, this won't get you exactly where you want. But it's a good direction.
Just remember: a <tr> gives you a new row, a <td> a new cell.

Hi Fonta, I really appreciate your time and the effort you took to respond to this, I can really use the help, I'm going to work on implimenting your suggestion and see what happens, first thing in the morning. This is something I've been working on for a while and I'm kind of excited to see what happens after applying your advice, I'll post the results back on this thread and let you know how it goes. Thanks again!

UPDATE:
okay I tried working with the tables but..
Hi, the weird thing is, this: {$impforum['threads']} shows the count for all 3 categories
so I would have no idea on how to seperate all three category counts based off of {$impforum['threads']}
Okay, so what you need to do is actually to add the ID.

Change this:
{$impforum['threads']}

to this:
{$impforum['fidID']}

Change ID to the id of the forum. You can see it down in left corner, when you hover it! :-)

Tell me if it works for you!
You can change the table lay-out to <div>s, then with CSS make each div 33.33% of one single parent <div>. Something like this: http://stackoverflow.com/a/20566735
@coxuco hey bro, thanks but no luck, nothing shows up, I've actually tried that one already.
@destroyer thanks for the link but with all the cross broweser issues using containers, that method is way too complicated for me. Believe me,I'm willing to try anything

I think that there has to be a way to simply call the count like
{$impforum_thread['fidID']}

anyhow I posted this as a job on seoclerk,
https://www.seoclerks.com/want/Programmi...ght-person
if one of you all can come up with a solution, I will gladly pay what I was going to pay on seoclerk, just give me your paypal email for accepting payments