MyBB Community Forums

Full Version: How can I add new page?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
A like creating a new php file with new Template. A tryed this, but I get empty page.
I created a proba.php file:
<?php
define("IN_MYBB", 1);
define('THIS_SCRIPT', 'proba.php');

$templatelist = "proba";
require_once "./global.php";
require_once MYBB_ROOT."inc/functions_post.php";
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;
?>
And I added new Template with proba name the next content:
{header}
I get empthy page and I don't understand that why not work. Can you help me?
I like creating new page without plugin.
(2010-08-11, 03:11 PM)atomjani Wrote: [ -> ]A like creating a new php file with new Template. A tryed this, but I get empty page.
I created a proba.php file:
<?php
define("IN_MYBB", 1);
define('THIS_SCRIPT', 'proba.php');

$templatelist = "proba";
require_once "./global.php";
require_once MYBB_ROOT."inc/functions_post.php";
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;
?>
And I added new Template with proba name the next content:
{header}
I get empthy page and I don't understand that why not work. Can you help me?
I like creating new page without plugin.

Ddi you create your custom template? Can you try this?

Add a template called proba_template with the following code in it:

<head>
<title>{$mybb->settings['bbname']} - Hello</title>
{$headerinclude}
</head>
<body>
{$header}
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td class="thead"><strong>Title of your custom page</strong></td>
</tr>
<tr>
<td width="100%" class="trow1">
{$custompagecontent}
</td>
</tr>
</table>
{$footer}
</body>
</html>

Then at your custom.php file add this code:

<?php


define('IN_MYBB', 1); 
require './global.php'; 


$custompagecontent = "//Enter here the contents for your custom page";

add_breadcrumb($title, "proba.php");
eval("\$custompage = \"".$templates->get("proba_template")."\";"); 
output_page($custompage); 
}
?>
I got error:
Parse error: syntax error, unexpected '}' in /var/www/virtual/forumvilag.com/htdocs/megujulas/proba.php on line 16
I deleted "}", after it's ok.
Thank you very much.Smile
And can I use the "{$custompagecontent}" code in other templates (example in header)?
(2010-08-11, 04:51 PM)atomjani Wrote: [ -> ]I got error:
Parse error: syntax error, unexpected '}' in /var/www/virtual/forumvilag.com/htdocs/megujulas/proba.php on line 16
I deleted "}", after it's ok.
Thank you very much.Smile
And can I use the "{$custompagecontent}" code in other templates (example in header)?

You are welcome Smile

I don't think that will work like that in the header. You should also add some php code in the relevant file to output the $custompagecontent variable. But can you tell me where do you want to display the custom content?
The content is not important now. But I want doing one new statistics board and some new functions.
I like use some function in new templates. I get this result:
[attachment=19456]
So I add this code:
require './stats.php'; 
I get the full stats.php in proba.php.
I like use example in proba templates:
{$lang->ppd} <strong>{$postsperday}</strong>

Have I put this code in proba.php?
// Get number of days since board start (might need improvement)
$query = $db->simple_select("users", "regdate", "", array('order_by' => 'regdate', 'limit' => 1));
$result = $db->fetch_array($query);
$days = (TIME_NOW - $result['regdate']) / 86400;
if($days < 1)
{
    $days = 1;
}
// Get "per day" things
$postsperday = my_number_format(round(($stats['numposts'] / $days), 2));
$threadsperday = my_number_format(round(($stats['numthreads'] / $days), 2));
$membersperday = my_number_format(round(($stats['numusers'] / $days), 2));
 
I think this is difficult and I would easier solution. This php code don't put the full stats.php. Example I put the {$postsperday} code in proba templates, the templates find this result in stat.php.
I hope you could understand the my problem.