MyBB Community Forums

Full Version: Using Page Manager to do PHP?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm using the Page Manager plugin but how would i execute php code using the page manager?

I'm trying an if statement i found this piece of code somewhere using google not sure if it's for this same plugin.

If anyone has knowledge using pagemanager please don't hesitate to post.
<table border="0" cellspacing="0" cellpadding="0" class="tborder2">
<tr>
<td class="trow1" valign="top" style="color: #FFFFFF; border-style:solid; border-color: #FF0000; border-width: 1px;" align="center">
<strong>Page is currently under construction</strong>
<if ($mybb->input['reason']) == "1" then>
Sorry you cannot do that

<else if ($mybb->input['reason']) == "2" then>
Sorry you don't have enough points

</if>

</td>
</tr>
</table>

edit: this is with using the theme
Everybody uses PageManager yet nobody knows how to do this....
(2012-01-13, 06:17 PM)Zodiac.Killer Wrote: [ -> ]I'm using the Page Manager plugin but how would i execute php code using the page manager?

I'm trying an if statement i found this piece of code somewhere using google not sure if it's for this same plugin.

If anyone has knowledge using pagemanager please don't hesitate to post.
<table border="0" cellspacing="0" cellpadding="0" class="tborder2">
<tr>
<td class="trow1" valign="top" style="color: #FFFFFF; border-style:solid; border-color: #FF0000; border-width: 1px;" align="center">
<strong>Page is currently under construction</strong>
<if ($mybb->input['reason']) == "1" then>
Sorry you cannot do that

<else if ($mybb->input['reason']) == "2" then>
Sorry you don't have enough points

</if>

</td>
</tr>
</table>

edit: this is with using the theme
Everybody uses PageManager yet nobody knows how to do this....
make sure that templates are turned off on the page you are making then perhaps the code should look more like this
<?php
global $headerinclude, $header, $theme, $footer, $templates, $lang, $user;
if ($GLOBALS['mybb']->user['usergroup'] == "1") 
$a='<br>Sorry you cannot do that';
if ($GLOBALS['mybb']->user['usergroup'] == "4") 
$a="<br> admin";
$template = '<html>
<head>
<title>' . $pages['name'] . '</title>
{$headerinclude}
</head>
<body>
{$header}
{$errors}
<table border="0" cellspacing="0" cellpadding="0" class="tborder2">
<tr>
<td class="trow1" valign="top" style="color: #FFFFFF; border-style:solid; border-color: #FF0000; border-width: 1px;" align="center">
<strong>Page is currently under construction</strong>
$a
</td>
</tr>
</table>

{$footer}
</body>
</html>';

$template = str_replace("\'", "'", addslashes($template));

add_breadcrumb($pages['name']);

eval("\$page = \"" . $template . "\";");

output_page($page);

?>
If you notice the if statements are not in the html code and are passed as variables to it .... so do the processing first add the oput to variables then build the html. hope this helps
When creating a new page, the Use MyBB Template? option needs to be set to No if you want to use PHP.

This might help you further - http://community.mybb.com/thread-63357.html
(2012-01-13, 08:24 PM)Alan Shepperson Wrote: [ -> ]When creating a new page, the Use MyBB Template? option needs to be set to No if you want to use PHP.

This might help you further - http://community.mybb.com/thread-63357.html

as I said in my post ... but added the code to reproduce the OP's content, with in that code I also showed that you can use $globals in php code but the result is the same I guess
Alan you didn't help, Jim you most likely solved my problem even though I knew it would be that. Would even setting the Use MyBB Template to no and using that code you provided still use the template?

edit: Thanks it works perfectly! Rep++
(2012-01-13, 09:10 PM)Zodiac.Killer Wrote: [ -> ]Alan you didn't help, Jim you most likely solved my problem even though I knew it would be that. Would even setting the Use MyBB Template to no and using that code you provided still use the template?

edit: Thanks it works perfectly! Rep++

No Problem !!!
some more code to look at
<?php
global $headerinclude, $header, $theme, $footer, $templates, $lang, $mybb;
if ($mybb->user['usergroup'] == "6") 
{
$a='<br>Sorry you cannot do that';
$av="<br>Hello ".$mybb->user['username'];}

elseif ($mybb->user['usergroup'] == "4") 
{$a="<br>".$mybb->settings['bbname'];
$av="<br>Hello ".$mybb->user['username'];
$b="<br>Email :- ".$mybb->settings['adminemail'];
}
//echo $av;
$template = '<html>
<head>
<title>' . $pages['name'] . '</title>
{$headerinclude}
</head>
<body>
{$header}
{$errors}
<table border="0" cellspacing="0" cellpadding="0" class="tborder2">
<tr>
<td class="trow3" valign="top" style="color: #000000; border-style:solid; border-color: #FF0000; border-width: 1px;" align="center">
$av<br>
<strong>This Page is currently under construction</strong><br>
thank you $a $b

</td>
</tr>
</table>

{$footer}
</body>
</html>';

$template = str_replace("\'", "'", addslashes($template));

add_breadcrumb($pages['name']);

eval("\$page = \"" . $template . "\";");

output_page($page);

?>
with this code I have added some extra variables and altered the 'if' statement, but I guess you new that Big Grin
(2012-01-13, 08:21 PM)JimR Wrote: [ -> ]
(2012-01-13, 06:17 PM)Zodiac.Killer Wrote: [ -> ]I'm using the Page Manager plugin but how would i execute php code using the page manager?

I'm trying an if statement i found this piece of code somewhere using google not sure if it's for this same plugin.

If anyone has knowledge using pagemanager please don't hesitate to post.
<table border="0" cellspacing="0" cellpadding="0" class="tborder2">
<tr>
<td class="trow1" valign="top" style="color: #FFFFFF; border-style:solid; border-color: #FF0000; border-width: 1px;" align="center">
<strong>Page is currently under construction</strong>
<if ($mybb->input['reason']) == "1" then>
Sorry you cannot do that

<else if ($mybb->input['reason']) == "2" then>
Sorry you don't have enough points

</if>

</td>
</tr>
</table>

edit: this is with using the theme
Everybody uses PageManager yet nobody knows how to do this....
make sure that templates are turned off on the page you are making then perhaps the code should look more like this
<?php
global $headerinclude, $header, $theme, $footer, $templates, $lang, $user;
if ($GLOBALS['mybb']->user['usergroup'] == "1") 
$a='<br>Sorry you cannot do that';
if ($GLOBALS['mybb']->user['usergroup'] == "4") 
$a="<br> admin";
$template = '<html>
<head>
<title>' . $pages['name'] . '</title>
{$headerinclude}
</head>
<body>
{$header}
{$errors}
<table border="0" cellspacing="0" cellpadding="0" class="tborder2">
<tr>
<td class="trow1" valign="top" style="color: #FFFFFF; border-style:solid; border-color: #FF0000; border-width: 1px;" align="center">
<strong>Page is currently under construction</strong>
$a
</td>
</tr>
</table>

{$footer}
</body>
</html>';

$template = str_replace("\'", "'", addslashes($template));

add_breadcrumb($pages['name']);

eval("\$page = \"" . $template . "\";");

output_page($page);

?>
If you notice the if statements are not in the html code and are passed as variables to it .... so do the processing first add the oput to variables then build the html. hope this helps

Just a thanks for the help, was searching all over the web to see how to do this.

To make a long story short, I was completely rigging my pages in pagemanager when using php to get the mybb theme integrated.

My code is 10x cleaner now, thanks!
(2013-04-22, 03:12 PM)warfront1 Wrote: [ -> ]
(2012-01-13, 08:21 PM)JimR Wrote: [ -> ]
(2012-01-13, 06:17 PM)Zodiac.Killer Wrote: [ -> ]I'm using the Page Manager plugin but how would i execute php code using the page manager?

I'm trying an if statement i found this piece of code somewhere using google not sure if it's for this same plugin.

If anyone has knowledge using pagemanager please don't hesitate to post.
<table border="0" cellspacing="0" cellpadding="0" class="tborder2">
<tr>
<td class="trow1" valign="top" style="color: #FFFFFF; border-style:solid; border-color: #FF0000; border-width: 1px;" align="center">
<strong>Page is currently under construction</strong>
<if ($mybb->input['reason']) == "1" then>
Sorry you cannot do that

<else if ($mybb->input['reason']) == "2" then>
Sorry you don't have enough points

</if>

</td>
</tr>
</table>

edit: this is with using the theme
Everybody uses PageManager yet nobody knows how to do this....
make sure that templates are turned off on the page you are making then perhaps the code should look more like this
<?php
global $headerinclude, $header, $theme, $footer, $templates, $lang, $user;
if ($GLOBALS['mybb']->user['usergroup'] == "1") 
$a='<br>Sorry you cannot do that';
if ($GLOBALS['mybb']->user['usergroup'] == "4") 
$a="<br> admin";
$template = '<html>
<head>
<title>' . $pages['name'] . '</title>
{$headerinclude}
</head>
<body>
{$header}
{$errors}
<table border="0" cellspacing="0" cellpadding="0" class="tborder2">
<tr>
<td class="trow1" valign="top" style="color: #FFFFFF; border-style:solid; border-color: #FF0000; border-width: 1px;" align="center">
<strong>Page is currently under construction</strong>
$a
</td>
</tr>
</table>

{$footer}
</body>
</html>';

$template = str_replace("\'", "'", addslashes($template));

add_breadcrumb($pages['name']);

eval("\$page = \"" . $template . "\";");

output_page($page);

?>
If you notice the if statements are not in the html code and are passed as variables to it .... so do the processing first add the oput to variables then build the html. hope this helps

Just a thanks for the help, was searching all over the web to see how to do this.

To make a long story short, I was completely rigging my pages in pagemanager when using php to get the mybb theme integrated.

My code is 10x cleaner now, thanks!

gr8 .... are you still using page manager or are you now using scripts that integrate into mybb ?