vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Change or Replace Variable! (https://vborg.vbsupport.ru/showthread.php?t=209357)

Super Jinni 03-25-2009 12:02 AM

Change or Replace Variable!
 
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:

PHP Code:

$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:

PHP Code:

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

Then in the template I do:
HTML Code:

<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:

PHP Code:

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

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

HTML Code:

<if condition="$test != 0">show something</if>
but nothing showed up.

then I tried using the following code:
HTML 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.


All times are GMT. The time now is 10:55 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01534 seconds
  • Memory Usage 1,732KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_html_printable
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete