MyBB Community Forums

Full Version: [Help !] MyBB & PHP
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've created a page called pages_qcfl.php here is the code inside :
<?php
define("IN_MYBB", 1); 

require "./global.php"; // (1)
 
  $pageOK = array('ana' => '../includes/html/ANA.html',
                  'atl' => '../includes/html/ATL.html');

  if ( (isset($_GET['page'])) && (isset($pageOK[$_GET['page']])) ) {
     include($pageOK[$_GET['page']]);   // Nous appelons le contenu central de la page
  } else {
     include('../includes/html/BOS.html');   // Page par défaut quant elle n'existe pas dans le tableau
  }

add_breadcrumb("Pages QcFL", "pages_qcfl.php"); // (2)

eval("\$pages_qcfl = \"".$templates->get("pages_qcfl")."\";"); // (3)
output_page($pages_qcfl); // (4)

?>

So the idea is to create a array to change the include ... but in MyBB I've created a template called pages_qcfl and inside I will put a variable :
<html>
<head>
<title>{$mybb->settings['bbname']}</title>
{$headerinclude}
</head>
<body>
{$header}
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<thead>
<tr>
<td class="thead"><strong>Pages QcFL</strong></td>
</tr>
<tbody>
<tr>
<td class="trow1"><p align="center">{$variable}</p></td>
</tr>
</tbody>
</table>
{$footer}
</body>
</html>

I don't know how to exaclty tweak the PHP code so that the output is the variable that will include the right page inside my template.
Sorry for the double post (a little bump), but I juste realise that my 1st post isn't that clear.

The thing I want to do, is one page that will work with pseudo-frames in PHP. My array will have over 90 possibilities and instead of creating 90 php files and 90 templates, I've decided to create only one.

I know how to make the include work in PHP (it works it the code above), but I don't know how to adapt it so it generate the right value to go inside the {$variable} in my template.

Can anybody help me on that !?

For example if I type this address, domain.com/pages_qcfl.php?page=ana, the code above will include ANA.html.
That's fine, but it overwrites everything ... I want it to be inside the variable.
Man it's like the 3rd request in a row, that I get 0 response ...
Change:
  if ( (isset($_GET['page'])) && (isset($pageOK[$_GET['page']])) ) {
     include($pageOK[$_GET['page']]);   // Nous appelons le contenu central de la page
  } else {
     include('../includes/html/BOS.html');   // Page par défaut quant elle n'existe pas dans le tableau
  }
To:
ob_start();
  if ( (isset($_GET['page'])) && (isset($pageOK[$_GET['page']])) ) {
     include($pageOK[$_GET['page']]);   // Nous appelons le contenu central de la page
  } else {
     include('../includes/html/BOS.html');   // Page par défaut quant elle n'existe pas dans le tableau
  }
$variable = ob_get_contents();
ob_end_clean();

Then you'd have whatever's in the html files within $variable.
Cool ! Sorry for the rant ;-)