Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-05-2013, 11:29 AM
eviljoker7075 eviljoker7075 is offline
 
Join Date: Dec 2008
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Include PHP in an advert

Hey I asked the following question over at vBulletin.com:
Quote:
I am using the ad management system in vBulletin (Admin CP> Advertising> Manage Ads). I would like to place an include to a php file in one of my ads. Is that possible?
They responded saying that I should ask at vbulletin.org and that it might be possible with a plugin... Can anyone help me out with that?

Basically, all I need to do is place an include to one php file in an advert. I don't mind hard coding the reference into the remplate if necessary, rather than going through the ad system.

Thanks
Reply With Quote
  #2  
Old 04-05-2013, 12:08 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You should be able to do something like this: create a plugin using hook location parse_templates, and code like this:

Code:
ob_start();
include "path/included_file.php";
$included_file = ob_get_contents();
ob_end_clean();

vB_Template::preRegister('template_name', array('included_file' => $included_file));

And then in the ad template, use {vb:raw included_file}. Of oucrse you need to use the actual path and file name, use the right template name for the ad location, and you can change 'included_html' to comething else if you want.
Reply With Quote
  #3  
Old 04-06-2013, 08:44 AM
eviljoker7075 eviljoker7075 is offline
 
Join Date: Dec 2008
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the suggestion, I've given it a go but it doesn't seem to work. Would you be able to sanity check what I've done?

1. I setup a new plugin with the following details:
Product: vBulletin
Location: parse_templates
Name: included_html
Code:
Code:
ob_start();
include "/path/to/file.php";
$included_file = ob_get_contents();
ob_end_clean();

vB_Template::preRegister('navbar', array('included_file' => $included_file));
2. Created an add
Location: Below Navbar
Ad HTML:
Code:
{vb:raw included_html}

What am I missing?

--------------- Added [DATE]1365242536[/DATE] at [TIME]1365242536[/TIME] ---------------

Ok, I can see my ad code should probably be:
Code:
{vb:raw included_file}
But even when I make that change nothing is showing up...
Reply With Quote
  #4  
Old 04-06-2013, 10:08 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by eviljoker7075 View Post
Ok, I can see my ad code should probably be:
Code:
{vb:raw included_file}
Yeah, sorry, that was a mistake in my post.

Try using 'ad_navbar_below' as the template name (in place of 'navbar').
Reply With Quote
  #5  
Old 04-06-2013, 10:21 AM
eviljoker7075 eviljoker7075 is offline
 
Join Date: Dec 2008
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No worries. It's still not working though :-/

Am I asking for an extra level of complexity here, I don't mind putting the variable directly into the template, would that be easier?
Reply With Quote
  #6  
Old 04-06-2013, 10:31 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You could certainly try that. So then you *would* use 'navbar' for the template name.

If that doesn't work, try temporarily adding a line to the plugin, like this:

Code:
ob_start();
include "/path/to/file.php";
$included_file = ob_get_contents();
ob_end_clean();

$included_file = "Included File";
vB_Template::preRegister('navbar', array('included_file' => $included_file));

and see if that shows up.
Reply With Quote
  #7  
Old 04-06-2013, 10:56 AM
eviljoker7075 eviljoker7075 is offline
 
Join Date: Dec 2008
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So I switched the template to 'navbar' and added in the {vb:raw included_file} line to the template directly and that worked!

I also tried your debug code (while using the ad too), but it had no effect.

I think I'll stick to putting the code directly into the template - but if you have any more suggestions why the original attempt failed I'd be interested in learning more.

Thanks!
Reply With Quote
  #8  
Old 04-06-2013, 11:15 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't see why it didn't work - I'd have to run some tests. But if you have it working, I guess it doesn't really matter which template you had to edit.
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 02:06 AM.


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.04759 seconds
  • Memory Usage 2,231KB
  • 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
  • (6)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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