PDA

View Full Version : phpinclude questions? (performance & # of items)


webwiz
07-26-2005, 07:15 PM
Hi,

I got phpinclude working as I want to add a special advertising contact form to my site... I entered this:

ob_start();
include('adform.php');
$adform = ob_get_contents();
ob_end_clean();

And it worked... But I have 3 other php files I need to call on seperate pages...

So the question is how can we add more than 1 include in the phpiclude template?

Also, I notice the index called the include file even though the variable isn't on index.php... Does the software automatically open all pages on the phpinclude template even though the variable isn't on those pages??

This seems like it would be major lag on the server...

WW

Andreas
07-26-2005, 07:18 PM
phpinclude_start will be executed on every page.

If you want to use file-dependant includes you can use


if (THIS_SCRIPT == 'showthread')
{
// Do smth. especially for showthread.php
}

webwiz
07-26-2005, 07:22 PM
So basically if I have 5 different php files in the phpinclude... the will be loaded when every forum page displays??? Hmmm... that will crush the server...

Is there anyway around this?

Andreas
07-26-2005, 07:26 PM
Edit the according .php-Files is the only possibility in vBulletin 3.0.X.
Or, as already said, use conditional includes.

Btw: Includes don't put a big burdon on the server - as long as there is no massive processing taking place in the included files.

webwiz
07-26-2005, 07:30 PM
Ok. I plan on using conditional comments... Just not sure how the code would be

ob_start();
$adform = ob_get_contents();
if (THIS_SCRIPT == 'contact')
{
include('adform.php');
}

$linkform = ob_get_contents();
if (THIS_SCRIPT == 'links')
{
include('linkform.php');
}
ob_end_clean();

Am I close?

Andreas
07-26-2005, 07:35 PM
I'd use a switch:


ob_start();
switch (THIS_SCRIPT) {
case 'contact':
include('adform.php');
break;
case 'links':
include('linkform.php');
break;
}
$includecontent = ob_get_contents();
ob_end_clean();

webwiz
07-26-2005, 07:41 PM
Ok I tried that but the pages come up blank without it...

So I tried this and it worked:

ob_start();
include("links.php");
$links = ob_get_contents();
ob_end_clean();

ob_start();
include("ad.php");
$adform = ob_get_contents();
ob_end_clean();