vBulletin ModsThe Official vBulletin Modifications Site
https://www.vbulletin.org/forum/showthread.php?t=326943 |
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:
How can I get and set that array as $arrayofuserids in template "conversation_userinfo" ? |
|
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:
Normally, I would expect variable $arrayofuserids is available in template, but is not. Don't know why. May I use the wrong hook (conversation_before_display_controls) ? |
You have to register your variable for your template (or register global)
In vB4 you can
Is vB5 the same syntax? http://vb5support.com/resources/api/...ethod_register |
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} |
Try {vb:debugvardump $arrayofuserids}
|
Result: NULL
|
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
The subdir name /testimportarray has to be the same as in class TestImportArray_Api_Arr and public $product = 'testimportarray'; 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
Then you can use the api function getArray in each template
|
I'll try that tomorrow. Thank you.
|
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. |
If you use a new API like ARR, make it your own API and don't extend it.
You could extend API like Page, Node, User... but why your own?!
There is a working example-mod here: https://vbulletin.org/forum/showthre...light=skeleton |
Quote:
--------------- Added 07 Dec 2018 at 05:41 --------------- One problem left. Why I cannot use that array in a condition?
Result:
But...
...works not. Solved. My solution:
Works, but isn't quite elegant. If there is a better way, I would be interested in. I want that array of userids also global. No need, to load on every post. |
Von hinten durch die Brust :D
|
Quote:
|
Dein Array-Inhalt sind strings. Du benötigst aber int.
liefert mir
und dann funktioniert es.
Deine Funktion sollte public function und nicht public static function sein. |
All times are GMT. The time now is 09:44. |
Powered by vBulletin® Version 3.8.14
Copyright © 2022, MH Sub I, LLC dba vBulletin. All Rights Reserved. vBulletin® is a registered trademark of MH Sub I, LLC
Copyright ©2001 - , vbulletin.org. All rights reserved.