vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   [Solved] variables in settings of product not work (https://vborg.vbsupport.ru/showthread.php?t=298691)

omardealo 06-03-2013 12:06 PM

[Solved] variables in settings of product not work
 
1 Attachment(s)
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 ...


https://vborg.vbsupport.ru/attachmen...1&d=1370264714

kh99 06-03-2013 12:55 PM

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.

omardealo 06-03-2013 01:35 PM

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] . '";'); 


kh99 06-03-2013 01:46 PM

Which hook did you use for your plugin, and which template are you putting the variable in?

omardealo 06-03-2013 01:51 PM

Quote:

Originally Posted by kh99 (Post 2425514)
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

kh99 06-03-2013 02:39 PM

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).

omardealo 06-03-2013 02:56 PM

thnx , kh99
i'm Sorry ... this code not worked too

kh99 06-03-2013 03:06 PM

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).

omardealo 06-03-2013 03:38 PM

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!

kh99 06-03-2013 03:55 PM

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.


All times are GMT. The time now is 05:05 AM.

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.01885 seconds
  • Memory Usage 1,764KB
  • 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
  • (2)bbcode_code_printable
  • (8)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete