• Welcome to ForumKorner!
    Join today and become a part of the community.

[MyBB Tutorial] Custom PHP Pages with ProPortal sidebars

Simple

Active Member
Reputation
0
NOTE: before you reply saying proportal has custom page support. i know it does but i wanted .php files with proper urls e.g forgottencoders.co.uk/p2map and not forgottencoders.co.uk/portalfilename.php?pages=p2map. ok so this is what needs to be done

hi guys my first tutorial prob not the best but i asked for help and didnt get any so i decided to do it my way.

first create a new .php file and then add this content to it. (the content is a stripped naked version of the proportal portal.php)

PHP:
<?php
define("IN_MYBB", 1); define("IN_PORTAL", 1);
$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_d​ay,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;
$lang->load("pro_portal");
$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;
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"; //page title
        eval("\$content = \"".$templates->get("TEMPLATE_NAME")."\";"); //replace templatename with your template
        add_breadcrumb("Title here", "FILENAME.php");  //custom breadcrumb and the filename of this file.
        eval("\$centerblocks .= \"".$templates->get("pro_portal_page")."\";"); //gets proportal structure
        eval("\$page = \"".$templates->get($portaltemplate)."\";"); //same as above
        output_page($page);
// end edit
?>

then edit this part of the code above changing the "PAGE HEADING", "Title Here", "FILENAME.php" and TEMPLATE_NAME

PHP:
// edit this bit below only
        $title = "PAGE HEADING"; //page title
        eval("\$content = \"".$templates->get("TEMPLATE_NAME")."\";"); //replace templatename with your template
        add_breadcrumb("Title here", "FILENAME.php");  //custom breadcrumb and the filename of this file.
        eval("\$centerblocks .= \"".$templates->get("pro_portal_page")."\";"); //gets proportal structure
        eval("\$page = \"".$templates->get($portaltemplate)."\";"); //same as above
        output_page($page);
// end edit 

finally create a new global template with the same name as in this line

PHP:
eval("\$content = \"".$templates->get("TEMPLATE_NAME")."\";"); //replace templatename with your template 

add whatever you want on the page to the new created template.

ENJOY. REPEAT FOR EACH PHP PAGE AND CHANGE TEMPLATE AND FILENAME AND TITLE HERE FOR EACH

Source: Brain, myBB​