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

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-03-2010, 02:03 PM
anakinjay anakinjay is offline
 
Join Date: Mar 2005
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Parsing php in templates with VB4?

Ok, so here's my situation:

I need to bring in data about each person in the post bit section from a drupal database. For example, each user has so many "points" based on lots of things outside of the forum in another database. I would like to display that in the author pane.

Getting the information using php is not an issue, I have that taken care of. What I need to understand is:

Where do I start in vbulletin? I *think* this should be a "product" but I'm new to VBulletin.

Where should I hook? I would *prefer* to just do some sort of global hook after the final template is created that goes back and replaces all <?php ?> areas with eval'd code. I've seen a VB3 product that can do this, but VB4 seems like it's broken that. Is there any place I can hook right after the final template is created (but before display), and then just go over it replacing stuff?

How do I get the user information of each post bit? I'm assuming there's some kind of replacement variable that represents the username?

thanks for the help!

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

With a few minor modifications, I got the old VB3 php parser product to work. This code only works for the footer though, you'll have to do copy the templatecache line for each template you want to use (unless someone has a suggestion for a better way.)

However, I *still* cannot figure out how to pass a variable to this PHP. I need to be able to do something like

<?php echo "{vb:raw ad_location.global_above_footer}"; ?>
(yes this example is useless, but it's a simple way to get my point across)

So basically, I need for {vb:raw ad_location.global_above_footer} to be replaced FIRST... THEN I want my code to fire.

Right now I'm hooking on parse_template. Would hooking in a different spot help?

PHP Code:
<?php

require_once(DIR '/includes/adminfunctions_template.php'); 

function 
let_php_live($matches) {

        return eval(
"ob_start();".$matches[2]."return ob_get_clean();");
}

$vbulletin->templatecache['footer']= preg_replace_callback('/(<\?=|<\?php|<\?)(.*)\?>/Us''let_php_live'$vbulletin->templatecache['footer']);

?>
Reply With Quote
 


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 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.04988 seconds
  • Memory Usage 2,238KB
  • Queries Executed 13 (?)
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)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)showthread_list
  • (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_threadedmode.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_threaded
  • showthread_threaded_construct_link
  • 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