The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
![]()
hello everyone, simple question; is it possible to register a php function as a variable (with a plugin I presume) then use it inside a template?
I have several small functions I want to be able to put on the same file and then execute them accordingly in each template or page that needs them. The other way I was doing it was just making a new file for each function (not as a function at that point of course), but it doesn't make sense to do several files when I can only do one. I was using the following plugin sort of successfully. It would register the function fine and parse it in the template but it would display the results of the function above the header at the beginning of the page (before the vb wrapper itself) and not where I placed the vb:raw inside the template. PHP Code:
If anyone can please spare a couple of minutes and explain why the output of the plugin is ending up way up there and which would be the right way of doing this I would be tremendously appreciative. Thank you for your time in advanced. Best regards. |
#2
|
|||
|
|||
![]()
If I remember correctly your function cotw_sotw_print_nom() calls "echo($id)" at the end, when I think what you want is to use return $id;
The reason it comes out at the top is because the vbulletin code works by gathering up all the output in a big string, which is then echoed at the end of the script. So if anything you do before that causes output (like calling echo() ), then it comes out before any other output (and so is at the top of the page). |
#3
|
|||
|
|||
![]() Quote:
PHP Code:
|
#4
|
|||
|
|||
![]()
Well, I see now why you were using the ob_start() and ob_end() orignially, because those let you capture the output to avoid having to change files like this. So, sorry if I misled you before, but it's difficult to answer one question without understanding everything you're trying to do.
So, there are two things you can do (well, at least two things): one would be to do like you were trying to do before: PHP Code:
The problem you were having before is that you were trying to include global.php which you don't need to do because it's been done already at this point. You probably just needed the "global $vbulletin" statement. The second way would be to change your function to collect up the output in a string instead of the multiple calls to echo, then return the string at the end. If you aren't comfortable with doing that, then you should probably just try the first option. |
#5
|
|||
|
|||
![]() Quote:
PHP Code:
|
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|