miniBB ® 

miniBB

®
Support Forums
  
 | Start | Register | Search | Statistics | File Bank | Manual |
Specific miniBB Support Forums / Specific /  
 

Wordpress' PHP Header/footer

 
 
Page  Page 1 of 2:  1  2  Next »

Author arthuc01
Partaker
#1 | Posted: 24 Jan 2004 13:39 
Hi

I'm trying to integrate MiniBB into my Wordpress based site but I have run into a few problems.

Basically the header and footer (including div contain menu) both use php in them.

Creating two files - header.php and footer.php
Adding to bb_plugins $myheadertop and $myfooter = includes for the relecvent php files
Then I delete all the content from main_header.html and main_footer.html and add in the respective {myheadertop}{myfooter}
To handle insertion of the php code into the html files of the template.

Now if I put plain text in both header.php and footer.php I get

this is plain text header

[ MiniBB content ]

this is plain text footer

If i add php to header php I get ....

this is php header (rendered as expected)

[ MiniBB content ]

this is plain text footer


But when I make both header and footer php I get

this is php header (rendered as expected)
this is php footer (rendered as expected)1
[ MiniBB content ] 1

(NB Number ones do appear)

Now I don't know why making footer.php contain php mucks up the rendering and its driving me up the wall does anyone have any ideas?

Author arthuc01
Partaker
#2 | Posted: 25 Jan 2004 22:12 
Okay heres where I've got to ...

bb_plugins contains the following...

<?php
$wpheader = include('./templates/wp_header.php');
$wpfooter = include('./templates/wp_footer.php');
?>

Main Header contains ....

{$wpheader}

<p>
{$l_menu[0]}{$l_menu[7]}{$l_menu[3]}{$l_menu[2]}{$l_menu[1]}{$l_menu[4 ]}{$l_menu[5]}{$l_menu[8]}{$l_menu[6]}{$l_sepr}</p>

Main footer.html contains ....

<p>{$l_adminpanel_link}</p>

<!--Copyright link. Having only free GPL licence, you can not remove it!-->
<p>Powered by <a href="https://www.minibb.com">miniBB {$version}</a> &copy; 2001-2004<p>
<!--End of copyright link-->

{$wpfooter}


Now what I think happens is that when the page is called rather than wait for the script to call {$wpfooter} {$wpheader} it appears that it just calls both them at the start of the page and then renders the rest of the content . Also prior to doing so it inserts the character 1

Any ideas guys??

Chris

Author arthuc01
Partaker
#3 | Posted: 25 Jan 2004 22:14 
Changing bb plugins to

<?php
$wpheader == include('./templates/wp_header.php');
$wpfooter == include('./templates/wp_footer.php');
?>

Gets rid of the 1 character but still renders incorrectly

Author Team
8-)
#4 | Posted: 29 Jan 2004 10:17 
The include() statement includes and evaluates the specified file. It doesn't return any value, so probably you can't associate it with variable.

Author Anonymous
Guest
#5 | Posted: 29 Jan 2004 23:59 
Sorry for the noobie question but how should I associate the include with the var and return the value?

Chris

Author Team
8-)
#6 | Posted: 30 Jan 2004 10:04 
After including some script, the variables and their values you get in this script are becoming available also in the script you are including from. Example: you have a.php:

<?
$var=1;
?>

You have b.php:

<?
include ('./a.php');
echo $var;
?>

The output you'll get will be "1".

Author arthuc01
Partaker
#7 | Posted: 30 Jan 2004 21:37 
Yes, but how do I set the vars
$wpheader and $wpfooter
equal to the generated content from
./templates/wp_header.php

From looking at http://uk.php.net/function.include

return.php
<?php

$var = 'PHP';

return $var;

?>


testreturns.php

<?php

$foo = include 'return.php';

echo $foo; // prints 'PHP'

?>

but when I do

<?php
$wpheader = include('./templates/wp_header.php');
$wpfooter = include('./templates/wp_footer.php');
?>

It just outputs the two php files automatically rather than waiting till $wpheader and $footer in the template header and footer html files

Author 4days
Champi0n
#8 | Posted: 1 Feb 2004 02:23 
<?php
$wpheader == include('./templates/wp_header.php');
$wpfooter == include('./templates/wp_footer.php');
?>

this won't work.

in your bb_plugins.php, include the two files, eg:

<?php
include('./templates/wp_header.php');
include('./templates/wp_footer.php');
?>

now when minibb calls bb_plugins.php it'll run those two php files. assuming that inside those files are the vars $wpheader and $wpfooter, you can put those vars in the templates and their values will be output to the page.

eg, wp_header.php could look like this:

<?php
$wpheader="my site";
?>

now when the template is parsed, it'll say 'my site' anywhere {$wpheader} appears.

Author arthuc01
Partaker
#9 | Posted: 8 Feb 2004 22:16 
The trouble I have with that is that if I want to include PHP in the header and footer.

If all I needed to do was include plain text I can do
bb_plugins.php....

<?php
$wpheader="my site";
$wpfooter="blah";
?>

And it would do the same thing as putting

<?php
$wpheader="my site";
?>

but If I want to use header or footer to pull say a dynamically generated menu I can't do it this way - or if I can I'm not good enough at PHP to realise how. (ie can't have

<?php
$wpheader="<?php some php script ?>";
?>

or can I?

Author Team
8-)
#10 | Posted: 9 Feb 2004 07:34 
arthuc01
:) yes you can .. you need to learn a bit programming though

for example in some php script there's $wpheader variable

you include this script in bb_plugins.php for example
using include 'somescript.php'; directive

and then $wpheader becomes available in all other files where bb_plugins.php is included(like index.php in our example) and in the bb_plugins.php itself of cours


I suggest you to read some tutorials about how basic php functions work and about php includes as well

Author rusty
Partaker
#11 | Posted: 6 Apr 2004 01:10 
maybe you can try this.

in your bb_plugins.php :

<?php

function execute($phpfile) {
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("file", "/dev/null", "a"),
);
$process = proc_open("php", $descriptorspec, $pipes);
if (is_resource($process)) {
$code = file_get_contents ($phpfile, true);
fwrite($pipes[0], $code);
fclose($pipes[0]);
$res="";
while(!feof($pipes[1])) {
$res .= fgets($pipes[1], 1024);
}
fclose($pipes[1]);
$phpfooter = $res;
proc_close($process);
}
return $res;
}

$phpheader = execute('./templates/php_header.php');
$phpfooter = execute('./templates/php_footer.php');

?>


good luck.

Rusty

Author Guest_Rik
Guest
#12 | Posted: 7 Mar 2007 17:38 
Hi,

thanks for that but when I do it like you explained I always get X-Powered-By: PHP/5.1.6 Content-type: text/html before the php include.

Any reason why?
Thanks

Author Paul
Lead Developer 
#13 | Posted: 8 Mar 2007 02:46 

Author Guest_Rik
Guest
#14 | Posted: 8 Mar 2007 06:20 
Thanks for the link, that's exactly what I was searching.

I do need to say that I did do Google searchs (for more than a half hour) without finding anything.
And that it was only after not finding anything that I posted here.

Author Paul
Lead Developer 
#15 | Posted: 8 Mar 2007 06:34 
Just curious: what kind of phrases to search have you entered?

I've entered just what you have posted here and found it within less than a minute...

Page  Page 1 of 2:  1  2  Next » 
Specific miniBB Support Forums / Specific /
 Wordpress' PHP Header/footer
 Share Topic's Link

Your Reply Click this icon to move up to the quoted message


  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Proceed with the Captcha add-on: protect your miniBB-forums from the automated spam and flood.


  ⇑