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

Reply
 
Thread Tools Display Modes
  #1  
Old 06-03-2013, 12:06 PM
omardealo's Avatar
omardealo omardealo is offline
 
Join Date: Nov 2008
Location: egypt
Posts: 235
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default [Solved] variables in settings of product not work

Hello ,

in my product ,i have a textarea setting and print it in a template
i try to put a vb variables in this option
like this
PHP Code:
$vboptions[bburl]
$bbuserinfo[userid
but not worked ...


Attached Images
File Type: png 6-3-2013 3-04-23 PM.png (3.9 KB, 0 views)
Reply With Quote
  #2  
Old 06-03-2013, 12:55 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you want to allow variables in your setting text, you need to use a plugin to eval() the text before using it in a template. For example:
Code:
eval('$my_setting = "' . $vbulletin->options[my_option] . '";');
Then use $my_setting in your template. If you do this, you should be aware that anyone who has access to the settings can execute any php code they want.

Using eval will allow you to use variables in your text. If you also want to use template tags (for example, <if condition=...), then you would need to use the template compiler.
Reply With Quote
  #3  
Old 06-03-2013, 01:35 PM
omardealo's Avatar
omardealo omardealo is offline
 
Join Date: Nov 2008
Location: egypt
Posts: 235
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you very much kh99 ,
i do this but not worked too

i used
PHP Code:
$points_pages 
in a templat ... text does not appear at all
PHP Code:
eval('$points_pages = "' $vbulletin->options[points_pages] . '";'); 
Reply With Quote
  #4  
Old 06-03-2013, 01:46 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Which hook did you use for your plugin, and which template are you putting the variable in?
Reply With Quote
  #5  
Old 06-03-2013, 01:51 PM
omardealo's Avatar
omardealo omardealo is offline
 
Join Date: Nov 2008
Location: egypt
Posts: 235
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
Which hook did you use for your plugin, and which template are you putting the variable in?
hook : misc_start

code :
PHP Code:
if ($_REQUEST['do'] == 'points')

$navbits construct_navbits(array(
        
'' => 'points'
    
));

eval(
'$navbar = "' fetch_template('navbar') . '";');
eval(
'print_output("' fetch_template('points_page') . '");');
eval(
'$pointspages = "' $vbulletin->options[pointspages] . '";');


i also try only eval() in hook : golbal_start and i put the variable $pointspages in header template ,to make sure the code is right but not worked too .


Thank you again
Reply With Quote
  #6  
Old 06-03-2013, 02:39 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm...OK, try this:
Code:
require_once(DIR . '/includes/functions_misc.php');
eval('$points_pages = "' . replace_template_variables($vbulletin->options[points_pages], true) . '";');

I think the variables $vboptions and $bbuserinfo may be shortcuts that only work templates, so the function replace_template_variables() will replace them with the longer version. (I haven't tried the above code, hopefully there aren't any errors).
Reply With Quote
  #7  
Old 06-03-2013, 02:56 PM
omardealo's Avatar
omardealo omardealo is offline
 
Join Date: Nov 2008
Location: egypt
Posts: 235
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thnx , kh99
i'm Sorry ... this code not worked too
Reply With Quote
  #8  
Old 06-03-2013, 03:06 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh, I didn't notice before, in your code you've done the eval() after the template eval() and it would have to be before. So try this code:

PHP Code:
if ($_REQUEST['do'] == 'points')

$navbits construct_navbits(array(
        
'' => 'points'
    
));

require_once(
DIR '/includes/functions_misc.php');
eval(
'$pointspages = "' replace_template_variables($vbulletin->options[points_pages], true) . '";');
eval(
'$navbar = "' fetch_template('navbar') . '";');
eval(
'print_output("' fetch_template('points_page') . '");');



And use $pointspages in your template (you have $point_pages above - of course you can use either one but make sure it is the same everywhere).
Reply With Quote
  #9  
Old 06-03-2013, 03:38 PM
omardealo's Avatar
omardealo omardealo is offline
 
Join Date: Nov 2008
Location: egypt
Posts: 235
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yes i know names of variables it not a problem , i take care and sure a bout it
look , i try everything

when i used ur code , and i put $vboptions[bbtitle] in setting
show me this error

PHP Code:
 Parse errorsyntax errorunexpected T_ENCAPSED_AND_WHITESPACEexpecting T_STRING or T_VARIABLE or T_NUM_STRING in misc.php(100) : eval()'d code(7) : eval()'d code on line 1 
and if i used code like this not show me error but also not show anthing
PHP Code:
eval('$navbar = "' fetch_template('navbar') . '";');
eval(
'print_output("' fetch_template('points_page') . '");');
require_once(
DIR '/includes/functions_misc.php');
eval(
'$pointspages = "' replace_template_variables($vbulletin->options[points_pages], true) . '";'); 

Thank you for your interest and suggestion!
Reply With Quote
  #10  
Old 06-03-2013, 03:55 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

As I mentioned before, your eval for $pointspages must be before the eval for your template. In fact, the function print_output() ends the script and never returns, so anything you put after that will not be executed (which is probably why the error goes away).

I'm trying to do this without trying it myself, so I'm not sure what the issue is. Maybe try this code:
PHP Code:
require_once(DIR '/includes/functions_misc.php');
eval(
'$pointspages = replace_template_variables("' $vbulletin->options[points_pages] . '");');
eval(
'$navbar = "' fetch_template('navbar') . '";');
eval(
'print_output("' fetch_template('points_page') . '");'); 

What is the text in your pointpages option? Is the text you posted above what you're using now? I'm asking because if it contains any quote characters that could cause problems.
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 11:43 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.05044 seconds
  • Memory Usage 2,302KB
  • Queries Executed 14 (?)
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
  • (2)bbcode_code
  • (8)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)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_postinfo_query
  • fetch_postinfo
  • 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_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete