PDA

View Full Version : Make includes easier!


stuuu
Mon 26th Aug '02, 5:12pm
I cant believe the amount of hassle involved in calling the vB header, footer, and styles into a custom vB page! I used an older version of vB a while back, and I managed to get it working without using the template system. It seems it is not possible in the current versions.

I would like to be able to do this in future versions of vB:

<?
include(global.php);
include(vBheader_code);
include(style_sheet_code);
!! My own PHP code here !!
include(vBfooter_code);
?>

Is this possible, as I managed to do it a while ago :/

Scott MacVicar
Mon 26th Aug '02, 5:18pm
you will need to require global.php and thats about it

<?php
include('./global.php');
echo $header;

// Own PHP Code here

echo $footer;
?>

stuuu
Mon 26th Aug '02, 5:24pm
Originally posted by PPN
you will need to require global.php and thats about it

<?php
include('./global.php');
echo $header;

// Own PHP Code here

echo $footer;
?>


Ah yes, but that does not process things like {titleimage} :/

Steve Machol
Mon 26th Aug '02, 5:25pm
Have you tried it yet? ;)

stuuu
Mon 26th Aug '02, 5:27pm
Originally posted by smachol
Have you tried it yet? ;)

lol yes :)

stuuu
Mon 26th Aug '02, 5:28pm
I have the code I was just given inside test.php

http://dnbforum.com/test.php

Steve Machol
Mon 26th Aug '02, 5:31pm
Well, to answer your question:

Ah yes, but that does process things like {categorybackcolor} :/Yes, if you've done it right. I have several pages set up like this and have had no problems whatsoever. Here's one:

http://www.optiboard.com/forums/title.php

Scott MacVicar
Mon 26th Aug '02, 5:33pm
In that case

<?php
include('./global.php');

$code = "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n
<html>\n
<head>\n
<title>$bbtitle</title>\n
$headinclude\n
</head>\n
<body>\n
$header";

$code .= '<img src="images/smilies/biggrin.gif">';
$code .= "$footer\n
</body>\n
</html>\n";
eval("dooutput(\"".addslashes($code)."\");");

?>

stuuu
Mon 26th Aug '02, 5:35pm
Originally posted by smachol
Well, to answer your question:

Yes, if you've done it right. I have several pages set up like this and have had no problems whatsoever. Here's one:

http://www.optiboard.com/forums/title.php

I see, that is exactly what I want. Inside my test.php I have:

<?php
include('./global.php');
echo $header;

// Own PHP Code here

echo $footer;
?>

That is giving me http://dnbforum.com/test.php - Im stuck then :/

If you right click, and hit properties on the logo, you get http://dnbforum.com/{titleimage} - it does not look like it is processing those curly bracket thingies :)

stuuu
Mon 26th Aug '02, 5:37pm
Originally posted by PPN
In that case

<?php
include('./global.php');

$code = "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n
<html>\n
<head>\n
<title>$bbtitle</title>\n
$headinclude\n
</head>\n
<body>\n
$header";

$code .= '<img src="images/smilies/biggrin.gif">';
$code .= "$footer\n
</body>\n
</html>\n";
eval("dooutput(\"".addslashes($code)."\");");

?>


Looks promising, trying now :)

Scott MacVicar
Mon 26th Aug '02, 5:37pm
Use my example above, you need to pass it through getoutput to do all the template replacements.

Scott MacVicar
Mon 26th Aug '02, 5:38pm
darn vB just replaced all my replacements :E

Scott MacVicar
Mon 26th Aug '02, 5:40pm
Try this
<?php
include('./global.php');

$code = "{htmldoctype}\n
<html>\n
<head>\n
<title>$bbtitle</title>\n
$headinclude\n
</head>\n
<body>\n
$header";

$code .= '<img src="{imagesfolder}/smilies/biggrin.gif">';
$code .= "$footer\n
</body>\n
</html>\n";
eval("dooutput(\"".addslashes($code)."\");");

?>

stuuu
Mon 26th Aug '02, 5:44pm
Originally posted by PPN
Try this
<?php
include('./global.php');

$code = "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n
<html>\n
<head>\n
<title>$bbtitle</title>\n
$headinclude\n
</head>\n
<body>\n
$header";

$code .= '<img src="images/smilies/biggrin.gif">';
$code .= "$footer\n
</body>\n
</html>\n";
eval("dooutput(\"".addslashes($code)."\");");

?>

Yup works, however, wouldnt I have to put all my code inside the $code var?

Isnt there a way to do it like smachol said? So my code is outside the $code var, like a normal PHP document.

stuuu
Mon 26th Aug '02, 5:47pm
Also, the PHP code does not get parsed through.

<?php
include('./global.php');

$code = "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n
<html>\n
<head>\n
<title>$bbtitle</title>\n
$headinclude\n
</head>\n
<body>\n
$header";
$code .= '<? print "php test"; ?>';
$code .= '<img src="images/smilies/new_slayer.gif">';
$code .= "$footer\n
</body>\n
</html>\n";
eval("dooutput(\"".addslashes($code)."\");");

?>

I added $code .= '<? print "php test"; ?>'; to the code, this will only appear in the HTML source.

Which brings me back to what I originally said about using the vB header, stylesheet, and footer in a page with my own PHP code.

:)

Scott MacVicar
Mon 26th Aug '02, 6:02pm
You just need to make sure that any output you have is appended to the code variable.

Such as


foreach($_SERVER as $name => $var) {
$code .= "$name is $var<br />\n";
}

stuuu
Mon 26th Aug '02, 6:06pm
Originally posted by PPN
You just need to make sure that any output you have is appended to the code variable.

Such as


foreach($_SERVER as $name => $var) {
$code .= "$name is $var<br />\n";
}

Got ya, I will try it out.

Question tho, have they changed the way you do this since vB 2.2.1? Because I had it working without putting it inside a $var a while back, I have lost my code though :o

I might setup the 2.2.1 locally to see if I can get it working again.

Scott MacVicar
Mon 26th Aug '02, 6:14pm
Not if you are creating your own page and want it to replace all the replacements as it has to pass through dooutput or dovars which would still have to be assigned to a variable.

John
Tue 27th Aug '02, 7:27am
Without wanting to complicate things more, you might want to look at the output buffering functions a bit:

http://uk.php.net/manual/en/ref.outcontrol.php

ob_start() ob_get_contents() and ob_end_clean() are all useful.

pagemaker
Tue 3rd Sep '02, 12:18pm
sorry maybe wrong thread but i cannot find specific thread to this:
i woul add custom footer but footer ist a separate php file.
i would like to include by useing include statement

include("r:/php/layout/lay2.php");
include("r:/php/layout/cnote.php");

the cnote.php should be the last output processed because i would like to use my own compression class.

how can i dop this ???