Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 11-22-2012, 03:00 AM
forumrunt forumrunt is offline
 
Join Date: Sep 2007
Posts: 177
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 11-22-2012, 12:15 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by forumrunt View Post
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.
Reply With Quote
  #3  
Old 11-22-2012, 10:29 PM
forumrunt forumrunt is offline
 
Join Date: Sep 2007
Posts: 177
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 11-22-2012, 11:26 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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();
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:24 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04399 seconds
  • Memory Usage 2,188KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (8)bbcode_code
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete