PDA

View Full Version : How to export php code to vbulletin?


mordor1
06-13-2010, 06:25 PM
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:

{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):

$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.