vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   How to export php code to vbulletin? (https://vborg.vbsupport.ru/showthread.php?t=244546)

mordor1 06-13-2010 06:25 PM

How to export php code to vbulletin?
 
Dear Vbulletin users,

I did read this
https://vborg.vbsupport.ru/showthread.php?t=228928

And this
https://vborg.vbsupport.ru/showthread.php?t=217569

But nothing works All i want to do is that this code works

<?php $userfuncties->showMenu (); ?>

Why does it have to be so complicated for a simple task? Scripts works fine when its not in vbulletin...

bleavitt 06-14-2010 05:42 PM

Hey Mordor1,

I just conclude a thread where I was running into a similar issue. I was a little frazzled that PHP functions wouldn't work in the templates either in v4.0. This has worked for me and it's not that much more complicated.

https://vborg.vbsupport.ru/showthread.php?t=243896

basically, in your specific template file (for example: 'header'), you create a new variable:

HTML Code:

{vb:raw show_menu}
where "show_menu" is the variable. Then down in the plugins/products menu, click on plugin manager, create a new plugin, set its hook to init_startup, and then add a bit of code that looks something like this (I've not tested this, of course):
PHP Code:

$server_varis=array();
$server_varis['show_menu']=$userfuncties->showMenu ();
vB_Template::preRegister('header'$server_varis); 

Note the use of 'header' in the third line corresponds directly with the specific template name where the code will be used. Then the array name can be whatever you like. It is not accessed from the template tags, just the name of the array key, which in this example was 'show menu'.

This is based off of what I just accomplished, so there may be some errors. But maybe this will help as well.

-Brent

mordor1 06-20-2010 08:17 AM

Tanks thought it dint worked error:
Fatal error: Call to a member function showMenu() on a non-object in /www/htdocs/ontwikk/forum4/includes/init.php(331) : eval()'d code on line 2

I had to enable //define('DISABLE_HOOKS', true); (in config.php) even the admin panel was broken.


All times are GMT. The time now is 01: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.02916 seconds
  • Memory Usage 1,719KB
  • 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
  • (1)bbcode_html_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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