View Full Version : How to read vbulletin->options from database?
Lionel
10-08-2007, 10:03 PM
I have a script that reads from database and write the data in a file.
What is the proper syntax for that please?
I tried putting in database:
<Background backgroundColor=\"".$vbulletin->options['mybg']."\"and
<Background backgroundColor=\"".$GLOBALS['vbulletin']->options['mybg']."\"They don't work.
Guest190829
10-08-2007, 11:16 PM
Not sure exactly what you are asking... We need a little more than a single line to see what you are doing.
EnIgMa1234
10-08-2007, 11:21 PM
I think he's trying to get a vbulletin option, to be added into a file, in the tag.
$vbulletin->options['mybg'] = #000000
So this would be added to the file:
<Background backgroundColor="#000000">
I think :D
Lionel
10-08-2007, 11:22 PM
OK. I am writing to an xml. If I put in the php:
$xml=bgcolor=".$vbulletin->options['mybg']." That is fine. The xml gets written with the correct value.
Now, if I put those in the db and do a query_first to retrieve it, then in the php I do
$xml=$myquery[result];
the xml gets written with the unconverted value for the option. It just displays bgcolor=".$vbulletin->options['mybg']." I tried the first post codes with no success.
Same goes for $vbphrase.
the very hard way I am trying to avoid would be to do a str_replace before I write to the xml. But there are so many options and phrases involved ...
Analogpoint
10-09-2007, 03:03 AM
Why are you manually writing options and phrases to a database? vB handles them all transparently. Just fire up a plugin for example and you can use $vbulletin->options without doing anything beforehand.
Lionel
10-09-2007, 03:27 AM
It has to be in database.
--------------- Added at 02:12 ---------------
No one can help?
Marco van Herwaarden
10-09-2007, 06:35 AM
Please show the full lines of code that is handling this, will be a lot easier to help you then.
Lionel
10-09-2007, 06:52 AM
The idea: I am releasing this slideshow mod found in my homepage (http://www.haitiwebs.com)
which auto updates: install and forget about it.
It's a dynamic flash slideshow that reads from an XML.
I decided to release it with 3 different layouts options. All was fine the way I did it with database, until I thought it would be neat to allow users to customize it to their taste. So in vb options they have 3 choices of layout. Plus they can make it the colors they want plus it uses phrases for the non english members..
So the plugins for when creating/updating/deleting a thread create an xml whenever there are actions in preset forums.
the template in database (lots of lines) so I am putting only this. $vbphrase are also involved.
etc... etc... <Background backgroundColor=\"".$vbulletin->options['cover_main_bg']."\" etc... etc...So depending on user choice, I select appropriate template from db and create the XML on the fly.
And as described in first post, what gets written in the xml is the raw code, no matter what I try.
Marco van Herwaarden
10-09-2007, 07:01 AM
What is the content of $template['template']?
Most likely the variable does not get parsed because of the stripslashes().
Lionel
10-09-2007, 07:05 AM
It's a lot of contents. I am putting the beginning only
If I don't escape it I can't put in database. And if I don't remove the slashes, they get written in xml too.
Paul M
10-09-2007, 07:05 AM
So if I'm reading this right - the code you are referring to is part of $template['template'] ?
If that's the case then yes, you will simply get the code - as all you are doing is getting the contents and storing them in $myxml. You would need to eval the contents - and they would need to be in a format that eval can handle.
Alternatively, you could store some unique text in the template where the value should go, and do a replacement on it after getting the contents.
Lionel
10-09-2007, 07:09 AM
Yeah. I thought of str_replace, but it's a lot of options and phrases.
Lionel
10-09-2007, 07:14 AM
In the attached example, I got no problem with getting from database as no customizations involved.
Dismounted
10-09-2007, 07:47 AM
As Paul has already mentioned, you need to evaluate the text of the template.
eval('$template = $template[\'template\'];');
$myxml = "/n/n" . $template . "/n";
Lionel
10-09-2007, 08:29 AM
As Paul has already mentioned, you need to evaluate the text of the template.
eval('$template = $template[\'template\'];');
$myxml = "/n/n" . $template . "/n";
Thanks, but that did not help.
I resorted doing it the hard way.
if ($template['template']==1){
all the code
}
else {
}
My php file went from 5k to 56k.
Thank you everyone for trying to help. I feel important in this thread. I had all the big guys in here :D
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.