MyBB Community Forums

Full Version: Add new custom PHP page.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10
(2012-08-08, 05:38 AM)crazy4cs Wrote: [ -> ]
(2012-08-07, 09:44 PM)Omar G. Wrote: [ -> ]You forget to add the template to the $templatelist variable, that will save you one query.
Hmm, where?


(2012-08-07, 09:21 PM)kamz89 Wrote: [ -> ]By the way, what if I want to add custom permissions, what code do I use?
As in disallow certain groups to see the page? Then you can use something like this:

if(in_array($mybb->user['usergroup'], array('2','8')))
{
error("Access denied");
}

You can replace 2 and 8 with any groups you want to disallow seeing that page. You can also add more groups to it to disallow them in a similar fashion.

Yes, I meant how to disallow certain groups. Thanks for the code.
I can't include PHP in global template. Please help
(2013-01-16, 12:19 PM)The Star Wrote: [ -> ]I can't include PHP in global template. Please help
Neither you're supposed to, in this tutorial. There are two parts, one that goes into global template, and the PHP stuff which is saved as a .php file.
(2013-01-16, 02:10 PM)crazy4cs Wrote: [ -> ]
(2013-01-16, 12:19 PM)The Star Wrote: [ -> ]I can't include PHP in global template. Please help
Neither you're supposed to, in this tutorial. There are two parts, one that goes into global template, and the PHP stuff which is saved as a .php file.
Here is the code which I want to add in global template:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
{$headerinclude}
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Search Engine Directory Submission</title>

<style type="text/css">
body {
padding:1px;margin: 0px;color: #333;font-size: 11px;font-family: arial, helvetica, sans-serif;background-color:#e3e3e3;}
img{border:0px;}
h2 {border-left: 10px solid #636563;font-size: 18px;padding:5px;margin:5px;}
a{color: #000000;text-decoration: none;}
a:hover{text-decoration: none;color: #cc0000;}
.content {padding:0px;border: #9c9c9c 1px solid;background: #fff;margin: 10px auto;
width: 560px;}
/** TOP **/
.mytop { height:52px;padding:5px 0px 0px 2px;background-color:#fFfCF;margin: 0px;}
.mytop h1{font-size: 26px;padding: 10px 26px 10px 26px;color: #000000;text-decoration:none;margin:0px;}
.mytop h1 a {text-decoration:none;color:#fff;}
.center {padding:5px 2px 5px 5px;float: left;margin: 0px;width: 550px;}
#menutop {height: 12px;padding:3px;font-size: 10px;font-weight: bold;margin: 0px;text-align: left;border:#A30100 solid 1px;background-color:#D10506;}
#menutop li {display: inline;list-style-type: none;}
#menutop ul {padding:0px;margin:0px;}
#menutop a {font-weight: bold;color: #fff;padding:3px;padding-right:10px;padding-left:10px;}
#menutop a:hover {background: #850303;color: #fff}
#menutop .lcurrent{background: #850303;color: #fff}
.footer {background-color:#EDEDED;text-align: center;color:#000;clear: both;padding: 10px 0px 0px 10px;
margin:10px 0px 0px 0px;border-top: #9C9A9C 2px dashed;
min-height:20px;
}
#sucess{border:#669966 1px solid;padding:3px;margin:3px;font-weight: bold;color:#669966;font-size:12px;text-align:center;}
#error{padding:3px;margin:3px;font-weight: bold;color:#FF0000;font-size:10px;display:inline;} 
</style>
</head>
<body>
{$header}
<div class="content">
<div class="mytop"><h1>Search Engine Directory Submission</h1></div>
<div id="menutop"></div>
<div class="center">


<?php
include("submit.php");
?>
    </p>
    </form>
   </div>
<div class="footer">
<div align="left" style="font-size:9px"></div></div></div>
{$footer}
</body></html>
There you may see the php code below ($header), that is necessary and without it the page will be unusable, I can't add that php code in .php file otherwise it will include submit.php below the footer. Any help?Huh
That'd be some "hack" that you'll need to adopt. For example all the stuff in your template till {$header} could be saved into one global template, then you evaluate in the php file. After that, you include your php file (submit.php). Now, make another global template and paste the remaining part of the code in it. Now, just like above, again use the template evaluate code so it will evaluate the remaining part after your file include.
(2013-01-16, 12:19 PM)The Star Wrote: [ -> ]I can't include PHP in global template. Please help

http://mybbhacks.zingaburga.com/showthread.php?tid=260

You can with this plugin.
(2013-01-16, 04:17 PM)crazy4cs Wrote: [ -> ]That'd be some "hack" that you'll need to adopt. For example all the stuff in your template till {$header} could be saved into one global template, then you evaluate in the php file. After that, you include your php file (submit.php). Now, make another global template and paste the remaining part of the code in it. Now, just like above, again use the template evaluate code so it will evaluate the remaining part after your file include.
You mean something like this?
<?php 

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

add_breadcrumb("Title here", "somename.php"); 

eval("\$html = \"".$templates->get("Search-Engine-Submitter")."\";"); 
output_page($html);
include("submit.php");
eval("\$html = \"".$templates->get("Search-Engine-Submitter")."\";");
output_page($html);

?>
Yeah, something along those lines. But make sure to make separate template (i.e. one part in the first, then includes, and then the rest).

(2013-01-16, 04:37 PM)weBex Wrote: [ -> ]
(2013-01-16, 12:19 PM)The Star Wrote: [ -> ]I can't include PHP in global template. Please help

http://mybbhacks.zingaburga.com/showthread.php?tid=260

You can with this plugin.
That's an excellent plugin, no doubt. But for little thing as what OP wants, a change will be good instead of installing a plugin.
Thanks @ crazy4cs and weBex. Rep+ Smile
Thank you Mr.crazy4cs for sharing this here, I like it.
Pages: 1 2 3 4 5 6 7 8 9 10