Log in

View Full Version : The making of a "new" php-file.


n1ckn4me
02-05-2005, 06:35 PM
I've made a whole new .php file that looks about the same a the $header but instead of $forumbits I have my own phpcode. I saved it and placed it in my root....

$stylevar[htmldoctype] $headinclude $header $navbar
65">$vbphrase[mycode_title]
65"> $vbphrase[mycode_body]
$footer


What do I need to program to make it happen ?
Is it something with phpinclude_start ?

Andreas
02-05-2005, 08:20 PM
*confused*

$header is a variable containing a parsed template (header), what you posted looks like part of an uncompiled template, you say you've created a new .php file (what's in it?) and you mention phpinclude_start.

So ... what do you actually want to achieve?

n1ckn4me
02-05-2005, 08:58 PM
sorry for the confusion...

My Idea of phpinclude_start was that you are only to be able to make a code that you could put in your $header or $footer. What I finally want is that I want to have a .php file that doesn't contain the forums but just my own made code that I've put in phpinclude_start...

does this make it more clear ?
and most of all how is this done ?

ps. KirbyDE thanks for your respond anyways...

Andreas
02-05-2005, 09:07 PM
No ;)
phpinclude_start will be executed on every page.
So if you want your code to be only executed on one page it' suggest to create a new php-file

You can use this as a start:

<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'myscript');

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array('mytemplate');

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################

// ** place your code here ***

eval('print_output("' . fetch_template('mytemplate') . '");');
?>

n1ckn4me
02-05-2005, 09:45 PM
This was just want I needed! although you didn't know what I wanted lol :P

I just have to ask what 'myscript' and 'mytemplate' is or with what I need to replace it ?

ps. thanks for the pations...

Andreas
02-05-2005, 09:48 PM
myscript is just an identifier (used for SQL error reports for example).
mytemplate is the Template that the script should output.

If you don't have/need a template: leave the array blank and remove the print_output line (but this will most likely be a pretty boring page then as it does not output anything ;))

n1ckn4me
02-05-2005, 10:12 PM
hmm well I still don't really get it but let me sleep it over :P
I surtenly aprieciate your helping hand !!

im just a noob trying to learn :p

Andreas
02-05-2005, 10:15 PM
Attach your code so we can see what you are trying to do.
Because without knowing that I can't help much more except giving general advices.

n1ckn4me
02-05-2005, 11:22 PM
ok you asked for it :p


I just didn't get it to work and that means I doing something wrong :(

The next code is de phpcode I want as a new .php-file... it's called "temp.php"
$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<!-- no cache headers -->
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<meta http-equiv="Cache-Control" content="no-cache" />
<!-- end no cache headers -->
<title><phrase 1="$vboptions[bbtitle]">$vbphrase[x_powered_by_vbulletin]</phrase></title>
$headinclude
</head>
<body>
$header
$navbar
<br />

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<thead>
<!-- message -->
<tr>
<td class="tcat" colspan="<if condition="$vboptions['showmoderatorcolumn']">6<else />5</if>">
<phrase 1="$vboptions[bbtitle]">$vbphrase[mypharse_title]</phrase></td>
</tr>
<tr>
<td class="alt1" colspan="<if condition="$vboptions['showmoderatorcolumn']">6<else />5</if>">
<table width="650" align="center">
<tr>
<td align="left" valign="top"><phrase 1="/link$session[sessionurl]">$vbphrase[myphrase_body]</phrase></td>
</tr>
</table>
</td>
</tr>
<!-- / message -->
</if>
</thead>
</table>

$footer
</body>
</html>

Andreas
02-05-2005, 11:32 PM
Hmm, I don't see any PHP-Code at all - only a template :)
Save this as a template (mytemplate for example) and use the PHP-File I posted above.

n1ckn4me
02-05-2005, 11:40 PM
ey!

ok so this called a template then..hehe

So I did what you said...I saved the template as "mytemplate.php" and I saved your earlier code as "facil.php" and uploaded that to my root so I would typ in my browser :

myhostdomain.com/facil.php

and than I get a blanco page that has as a sourcecode:

<html><body></body></html>

?? did I forgot something ?

thanks for sticking with me on this one!!

Michael Morris
02-06-2005, 04:09 AM
For information on what $PHP_Include start can do check my sig.

Andreas
02-06-2005, 04:35 AM
So I did what you said...I saved the template as "mytemplate.php" and I saved your earlier code as "facil.php"
No, you should save the template as a template - not as a file.

Got ro youre Admin Control Panel, Select Styles & Templates, Style Manager.
Then on the right, from the dropdown select Add New Template, sace it under the name you have in facil.php

n1ckn4me
02-06-2005, 11:54 AM
Thanks Michael Morris! I've read your tut before I posted this thread and found it very usefull to understand how about using the phpinclude_start but KirbyDE showed me that it isn't really nessesry for what I wanted to do... thanks for your respond anyways :)

ey KirbyDE..
I know understand how this works! and guess what...IT WORKS!! :D
Im sooo glad you sticked to till the end with me!! I learned alot from you!
Thanks again for the help and will catch ya soon on the boards I guess ;)