MyBB Community Forums

Full Version: ProPortal sidebar in custom .php pages
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
essentially as the title says.

how do i put the ProPortal sidebar in custom .php pages

thanks.

bump....


i want to put the sidebar from pro_portal in either page manage plugin (proportal pages doesnt work well with rewriterules) or in custom.php pages please help.
ok so i kinda did a hacky fix lol.

i rippped out most the code from portal.php of proportal and added my own along with a custom template here

<?php
define("IN_MYBB", 1);
define("IN_PORTAL", 1);
define('THIS_SCRIPT', 'index.php');

$change_dir = "./";

$templatelist = "pro_portal,pro_portal_left,pro_portal_page,pro_portal_right,pro_portal_block,pro_portal_announcement,calendar_mini,calendar_mini_weekrow,calendar_mini_weekrow_day,calendar_mini_weekdayheader, multipage, multipage_nextpage, multipage_page, multipage_page_current";

require_once $change_dir."/global.php";
require_once MYBB_ROOT."portal/inc/portal.class.php";
$proportal = new ProPortal;

// Load portal language phrases
$lang->load("pro_portal");

// Construct portal settings
$options = array(
	"order_by" => "id",
	"order_dir" => "ASC"
);
$query = $db->simple_select("portal_settings", "*", "", $options);
while($setting = $db->fetch_array($query))
{
	$setting['value'] = str_replace("\"", "\\\"", $setting['value']);
	$settings[$setting['name']] = $setting['value'];
}
$proportal->settings = &$settings;

// Choosing portal template by column setting
if($proportal->settings['portalcolumns'] == "left"){ $portaltemplate = "pro_portal_left"; }
elseif($proportal->settings['portalcolumns'] == "right"){ $portaltemplate = "pro_portal_right"; }
else{ $portaltemplate = "pro_portal"; }

if($proportal->settings['portalcolumns'] == "left" || $proportal->settings['portalcolumns'] == "both")
{
	// Getting left blocks
	if ($fetch_blocks = $proportal->get_list("SELECT * FROM ".TABLE_PREFIX."portal_blocks WHERE zone='0' AND enabled='1' AND visible REGEXP '[[:<:]]".$mybb->user['usergroup']."[[:>:]]' ORDER BY position")) {
		foreach ($fetch_blocks as $result_blocks) {
			$title = $result_blocks['title'];
			$file = $result_blocks['file'];
			$content = $result_blocks['content'];
			
			// Collapse block thing
			$expdisplay = '';
			$collapsed_name = "block_{$result_blocks['id']}_c";
			if(isset($collapsed[$collapsed_name]) && $collapsed[$collapsed_name] == "display: show;")
			{
				$expcolimage = "collapse_collapsed.gif";
				$expdisplay = "display: none;";
				$expaltext = "[+]";
			}
			else
			{
				$expcolimage = "collapse.gif";
				$expaltext = "[-]";
			}
			
			if($file != "0"){
				if (file_exists(MYBB_ROOT."portal/blocks/block_$file.php")) {
					ob_start();
					include_once(MYBB_ROOT."portal/blocks/block_$file.php");
					$content .= ob_get_contents();
					ob_end_clean();
				} else {
					$content = $lang->block_file_missing;
				}
			} else {
				$content = $result_blocks['content'];
			}
			
			if($result_blocks['custom'] == "0"){
				eval("\$leftblocks .= \"".$templates->get("pro_portal_block")."\";");
			} else {
				$leftblocks .= "<div style=\"padding-bottom:".$proportal->settings['horizontalspace']."px;\">".$content."</div>";
			}
		}
	} else {
		$title = $lang->left_block_none;
		$content = $lang->left_block_none_content;
		eval("\$leftblocks = \"".$templates->get("pro_portal_block")."\";");
	}
}

if($proportal->settings['portalcolumns'] == "right" || $proportal->settings['portalcolumns'] == "both")
{
	// Getting right blocks
	if ($fetch_blocks = $proportal->get_list("SELECT * FROM ".TABLE_PREFIX."portal_blocks WHERE zone='2' AND enabled='1' AND visible REGEXP '[[:<:]]".$mybb->user['usergroup']."[[:>:]]' ORDER BY position")) {
		foreach ($fetch_blocks as $result_blocks) {
			$title = $result_blocks['title'];
			$file = $result_blocks['file'];
			$content = $result_blocks['content'];
			
			// Collapse block thing
			$expdisplay = '';
			$collapsed_name = "block_{$result_blocks['id']}_c";
			if(isset($collapsed[$collapsed_name]) && $collapsed[$collapsed_name] == "display: show;")
			{
				$expcolimage = "collapse_collapsed.gif";
				$expdisplay = "display: none;";
				$expaltext = "[+]";
			}
			else
			{
				$expcolimage = "collapse.gif";
				$expaltext = "[-]";
			}
			
			if($file != "0"){
				if (file_exists(MYBB_ROOT."portal/blocks/block_$file.php")) {
					ob_start();
					include_once(MYBB_ROOT."portal/blocks/block_$file.php");
					$content .= ob_get_contents();
					ob_end_clean();
				} else {
					$content = $lang->block_file_missing;
				}
			} else {
				$content = $result_blocks['content'];
			}
			
			if($result_blocks['custom'] == "0"){
				eval("\$rightblocks .= \"".$templates->get("pro_portal_block")."\";");
			} else {
				$rightblocks .= "<div style=\"padding-bottom:".$proportal->settings['horizontalspace']."px;\">".$content."</div>";
			}
		}
	} else {
		$title = $lang->right_block_none;
		$content = $lang->right_block_none_content;
		eval("\$rightblocks = \"".$templates->get("pro_portal_block")."\";");
	}
}
// edit this bit below only
	
		$title = "PAGE HEADING";
		$content = $page_data['content'];
		add_breadcrumb("Title here", "FILENAME.php"); 
		eval("\$centerblocks .= \"".$templates->get("CUSTOM GLOBAL TEMPLATE")."\";");
		eval("\$portal = \"".$templates->get($portaltemplate)."\";");
		$plugins->run_hooks("pro_portal_end");
		output_page($portal);
// end edit
?>

ok so replace PAGE HEADING with a page heading, Filename.php with your filename, Title here with your breacrumb title and CUSTOM TEMPLATE with you cloned pro_portal_page template
<div style="padding-bottom:{$proportal->settings['horizontalspace']}px;">
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td class="thead"><strong>{$title}</strong></td>
</tr>
<tbody>
<tr>
<td class="trow1">
{$content}
ADD YOU CONTENT HERE
</td>
</tr>
</tbody>
</table>
</div>

ok made it more efficient now.

http://community.mybb.com/thread-118941.html