vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Very Easy Request (https://vborg.vbsupport.ru/showthread.php?t=46905)

eckels2 12-22-2002 04:49 PM

Very Easy Request
 
I have a javascript that loads when the page loads. I would like the user to be able to turn it on or off. That is, i want the user to have the option of the script loading when the page loads, or not loading.

How i'd like to do it, is to either use a cookie, or a field in the database to store a value, that says whether or not the script should run when the page loads.

I imagine the cookie would be easier.

Can anyone give me a general idea of what to do? or help me out with some php that does something like that?

Logician 12-22-2002 07:40 PM

How about this:

Create a new userprofile field in Admin CP hidden in profile but editable by the users, note its id

Tell your users to enter "YES" there if they want to load the script.

Then edit global.php, find:
PHP Code:

// parse PHP include ################## 

Before that add:

PHP Code:

if (strtolower($bbuserinfo[fieldX])=='yes') {$yourjavacode='ENTER CODE HERE';} 

(Replace X with your field id)

Then you can use "$yourjavacode" variable in your relavant template like header..

eckels2 12-27-2002 01:59 AM

it doesn't seem to parse $yourjavacode. it just leaves "$code" in the page, without it being replaced by the actual code.

what it thought of, is it might be my code that i'm trying to replace it with... the necessary java code is onLoad="snow()"...

so it looked like if (strtolower($bbuserinfo[field6])=='yes') {$yourjavacode='onLoad="snow()"';}

Should i do it differently? is that the problem?

filburt1 12-27-2002 02:39 AM

No need to hack; I mean you just referenced PHPinclude...install this first (I can never remember the eval template code) and then add this:

PHP Code:

if (strtolower($bbuserinfo['field[i]n[/i]']) == "yes")
{
    eval(
makeevaltemplatecode("jscodeinsert""templatenamethathasonlythejavascriptinit"));


Then insert $jscodeinsert wherever you want the code to go.

Logician 12-27-2002 08:55 AM

Quote:

Originally posted by eckels2
it doesn't seem to parse $yourjavacode. it just leaves "$code" in the page, without it being replaced by the actual code.

what it thought of, is it might be my code that i'm trying to replace it with... the necessary java code is onLoad="snow()"...

so it looked like if (strtolower($bbuserinfo[field6])=='yes') {$yourjavacode='onLoad="snow()"';}

Should i do it differently? is that the problem?

You should be inserting the "$yourjavacode" variable into the wrong template. I tested it by inserting it into "headinclude" template and it works as it should be..


All times are GMT. The time now is 05:57 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.01173 seconds
  • Memory Usage 1,725KB
  • 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_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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