vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   PHP Include by thread name? (https://vborg.vbsupport.ru/showthread.php?t=291292)

forumrunt 11-22-2012 03:00 AM

PHP Include by thread name?
 
I'm php include coding listed below to put banners on the sides of my site.
I'm trying to figure out how I would be able to code it, that in the include it would load a different include depending on the thread name?

example:
A thread titled "Bobs Banner" would pull bobs-banner-include.php.

I have searched and not found anything as of yet, I'm not sure if I'm using the right terminology, this is all new to me, any questions or suggestions please let me know.

Coding I'm currently using

Hooked to global_start Plugin with
Code:

ob_start();
include('/includes/banner.php');
$includedphp = ob_get_contents();
ob_end_clean();


In the template..
Code:

<td width="100px" padding="5px">$includedphp</td>
banner.php
Code:

<body>
<img src="/images/banners/banner.jpg" width="90" height="200">
</body>

UPDATED:
I tried
Code:

ob_start();
include('/includes/$pagenumber.php');
$includedphp = ob_get_contents();
ob_end_clean();

Then renamed the banner.php to 24.php(the forumdisplay id) to no avail :(

kh99 11-22-2012 12:15 PM

Quote:

Originally Posted by forumrunt (Post 2383560)
UPDATED:
I tried
Code:

ob_start();
include('/includes/$pagenumber.php');
$includedphp = ob_get_contents();
ob_end_clean();

Then renamed the banner.php to 24.php(the forumdisplay id) to no avail :(


I think that might work, but use double quotes, like

Code:

ob_start();
include("/includes/$pagenumber.php");
$includedphp = ob_get_contents();
ob_end_clean();

Also you might need a '@' before 'include' to ignore the error if the file doesn't exist.

forumrunt 11-22-2012 10:29 PM

Thanks, I tried


Warning: include(/includes/24.php) [function.include]: failed to open stream: No such file or directory in [path]/global.php(404) : eval()'d code on line 242
Code:

ob_start();
include("/includes/$pagenumber.php");
$includedphp = ob_get_contents();
ob_end_clean();

But still got
Quote:

Warning: include() [function.include]: Failed opening '/includes/24.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in [path]/global.php(404) : eval()'d code on line 242
Sorry what did you mean by
Quote:

Also you might need a '@' before 'include' to ignore the error if the file doesn't exist.

kh99 11-22-2012 11:26 PM

You might need ./includes instead of includes, but it depends on where you put your banner files. The other thing I mentioned is that if you put a '@' before statement it will cause errors to be ignored, so that if there's a thread without a banner, it won't cause an error (maybe that's not a problem if you are going to guarantee that every thread has a corresponding file). So, maybe this:

Code:

ob_start();
@include("./includes/$pagenumber.php");
$includedphp = ob_get_contents();
ob_end_clean();



All times are GMT. The time now is 07:04 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01082 seconds
  • Memory Usage 1,724KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (8)bbcode_code_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete