Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-25-2009, 12:02 AM
Super Jinni Super Jinni is offline
 
Join Date: Mar 2008
Posts: 437
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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 )

- 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
Reply With Quote
  #2  
Old 03-26-2009, 12:46 AM
Super Jinni Super Jinni is offline
 
Join Date: Mar 2008
Posts: 437
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

anyone?!!!
Reply With Quote
  #3  
Old 03-26-2009, 02:40 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 03-26-2009, 04:02 AM
Super Jinni Super Jinni is offline
 
Join Date: Mar 2008
Posts: 437
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 03-26-2009, 02:26 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 03-26-2009, 06:50 PM
Super Jinni Super Jinni is offline
 
Join Date: Mar 2008
Posts: 437
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:27 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04335 seconds
  • Memory Usage 2,215KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_html
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete