Log in

View Full Version : Change or Replace Variable!


Super Jinni
03-25-2009, 12:02 AM
Hi,
I'm doing my first vbulletin product. and everything seems to be OK as I'm trying to figure out how is everything is working with vbulletin.

I came across this issue:
(my English is not that good and I'm afraid I won't be able to perfectly explain my issue, so please bear with me :p)

- I added templates and phrases and plugins.
- I added new setting group for my product.
- Chose the varname and title and other required things as well.
- Then added settings for my products and set if () in it's plugin and everything seems to be fine till now.
- then I added other setting with a blank field under the (Option Code) and chose it's varname which is rtrf_xxx_yyy.

Now, this varname should be an element of an array. and it should be $vbulletin->options['rtrf_xxx_yyy'] when called, right?

I just want to replace or change this variable (array element) and move it's value to a new variable so that I can use the new variable within the templates of my product instead of using $vbulletin->options['rtrf_xxx_yyy'], but I didn't know how to do that!

I've tried this in the plugin:

$test = $vbulletin->options['rtrf_xxx_yyy']; and then used the variable $test in the template but nothing showed up or happened.

But it works fine if I use {$vbulletin->options['rtrf_xxx_yyy']} within the template.

So my question is:
- How to replace $vbulletin->options['rtrf_xxx_yyy'] with a variable like $test and be able to use $test in the template that I need and make it shows up where I want in the forum?
- Does it matter where the hook is for variable replacement or variable changing?

Hope I did well explaining my issue, and hope I can get a fast reply ASAP.

thanks :)

Super Jinni
03-26-2009, 12:46 AM
anyone?!!!

Lynne
03-26-2009, 02:40 AM
I'm not sure if I understand what you are asking. I have an array in one of my products called $vbulletin->options[verify_forums]. It is a bunch of forumids. In order to use them in a template, I do the following:

$vfarray=$vbulletin->options[verify_forums];
$verifyforums = explode(",", $vfarray);

Then in the template I do:
<if condition="in_array($threadinfo[forumid], $verifyforums)">I'm not sure if that is what you were looking for.

Super Jinni
03-26-2009, 04:02 AM
it's somehow similar but not exact.
I'll try again to explain what I'm looking for.

I have a variable in one of my product. it's not an array.
this variable called $vbulletin->options['rtrf_xxx_yyy'] as it has only one value. not many values as in array.

so, I tried to use this variable in a template, in order to do that I did the following:

$test=$vbulletin->options['rtrf_xxx_yyy'];

then I put the variable $test in a template as the following:

<if condition="$test != 0">show something</if>

but nothing showed up.

then I tried using the following code:
<if condition="$vbulletin->options['rtrf_xxx_yyy'] != 0"> show something</if> and it worked just fine as I want it.

then I tried to put only $test variable in the template to see if it gonna show up. but it didn't.

I -then- put $vbulletin->options['rtrf_xxx_yyy'] and it shows me Array['rtrf_xxx_yyy']


then I put {} around the variable like this {$vbulletin->options['rtrf_xxx_yyy']} and it works fine and showes me what I want.

I'm just wondering why it did not work when I use $test but work fine when I use {$vbulletin->options['rtrf_xxx_yyy']} although I already set $test value as I mentioned above. $test=$vbulletin->options['rtrf_xxx_yyy'];

what I want exactly is to use $test in the template instead of $vbulletin->options['rtrf_xxx_yyy']. but I couldn't make it work or show up.

Lynne
03-26-2009, 02:26 PM
I'm not sure why it isn't working. Perhaps $vbulletin needs to be defined as global in the php code prior to defining $test.

Also, in templates, you should use $vboptions instead of $vbulletin->options.

Super Jinni
03-26-2009, 06:50 PM
OK Lynne, it finally worked after I changed the hook location.
wasn't sure that does matter specially when I used other codes and variables in the same hook location.

thanks for pointing that to me. and thanks for $vboptions thing. that really was helpful.

Regards.