The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Make array usable in template
I need an array of userids in template "conversation_userinfo". This array is written in a html or php file.
HTML-File: 1,2,3,4.... PHP-File:echo array(1,2,3,4...); It should be used like: Code:
<vb:if condition="in_array($conversation['userid'], $arrayofuserids)">...</vb:if> |
#2
|
||||
|
||||
Try this:
Code:
{vb:set arrayofuserids, {vb:php array, 1, 2, 3, 4}} |
#3
|
||||
|
||||
Hey noypiscripter,
thanks, but this is not, what I ask for. I ask for an example, how to get the array from file into a variable in template. I set a hook: Code:
ob_start(); include('path/arrayofuserids.php'); $arrayofuserids=ob_get_contents(); ob_end_clean(); |
#4
|
|||
|
|||
You have to register your variable for your template (or register global)
In vB4 you can PHP Code:
http://vb5support.com/resources/api/...ethod_register |
#5
|
||||
|
||||
Here: https://www.vbulletin.com/docs/html/..._externalfiles they say it is needed on 4+. Logic, 5>4.
I'll try. EDIT: I get no result. Neither for {vb:raw $arrayofuserids} nor {vb:raw arrayofuserids} |
#6
|
|||
|
|||
Try {vb:debugvardump $arrayofuserids}
|
#7
|
||||
|
||||
Result: NULL
|
#8
|
|||
|
|||
Ok, my mistake. It seems that vB5 doesn't have a plugin/hook system like vB4. The hooks you see are template hooks, you need php hooks.
For my addons I use only api extensions Simple example: - create in /forum/core/packages a subdir /testimportarray/api - create a file arr.php PHP Code:
The subsubdir name /api is repeated in class TestImportArray_Api_Arr The filename arr.php has to be the same like in class TestImportArray_Api_Arr Then check in AdminCP/Add-ons & Hooks/Api Extensions and PHP Hooks if your Api is listed without error Code:
Add-on: testimportarray TestImportArray (1.0.0) TestImportArray_Api_Arr Ja 5.0.0 6.0.0 Alpha 1 Ja 5 PHP Code:
|
#9
|
||||
|
||||
I'll try that tomorrow. Thank you.
|
#10
|
||||
|
||||
Quote:
Anyway, follow what @shka suggested which is using API extensions. An alternative is to use frontend controller. Frontend controller functions are also accessible from the template. But using API extensions is cleaner and more elegant. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|