The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
![]()
Hello,
I have some PHP code that generates a random hex color code. I would like to incorporate it for use in vbulletin (it has to be server side). In a normal PHP file, the output is something like $randomcolor. Does anyone know how to get that to be displayed properly within VB using the plugin system (if that's the proper way to do it)? |
#2
|
||||
|
||||
![]()
Stick the PHP code in a new plugin using the "global_start" hook. $randomnumber should then be available to use in most templates.
|
#3
|
||||
|
||||
![]()
Best way is to put the code in a plugin for global_start and then call the variable you are using for it wherever you want to use it.
|
#4
|
|||
|
|||
![]()
wow, fast replies, many thanks.
Is it simply called with $randomnumber ? Or does it need some {} or [] ? |
#5
|
||||
|
||||
![]() Quote:
|
#6
|
|||
|
|||
![]()
OK, the code I plan on using is from here:
http://www.zend.com/tips/tips.php?id=243&single=1 My rendition is below: Code:
<? // randomize the color $r = rand(128,255); $g = rand(128,255); $b = rand(128,255); $randomcolor = dechex($r) . dechex($g) . dechex($b); ?> |
#7
|
||||
|
||||
![]()
Okay, in your plugin, do NOT include the PHP tags (<? and ?>). Everything else looks okay - be sure to add the # in front of $randomcolor when you use it. And no, you won't need any []s or {}s.
|
#8
|
|||
|
|||
![]()
OK, thanks again for the quick reply. I'm trying to use it in the postbit_legacy to display in posts, but nothing is showing.
Should I call it differently for there? |
#9
|
||||
|
||||
![]() Quote:
PHP Code:
If you want them all the same: postbit_display_complete PHP Code:
|
#10
|
|||
|
|||
![]()
Fantastic! My deepest thanks. I'm actually using as part of an included JS script that needs an image border color and it works well now! Thanks!
|
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|