Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #11  
Old 07-15-2012, 09:20 AM
Mko's Avatar
Mko Mko is offline
 
Join Date: May 2009
Location: East Coast, USA
Posts: 60
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
Hmm...well I was thinking you might be able to fix the problem on the php side by changing what value you're giving the RULES var, and that would require another plugin instead of just using $vboptions[ishout_rules] directly in a template. But maybe I don't understand what the issue is. Is it all working except that InfernoShoutbox.userframe doesn't show the right value, or does it not work at all because the "var RULES = " line isn't valid js?
Forgive me, I might've been unclear, haha

Basically, here's what I've got (my whole .js code):
http://paste2.org/p/2073301#line-549
As you can see, I'm already modifying the variable RULES on line 549 to change all \n tags to be <br />.

Now, the RULES var is called from an option in a setting on my Forum. In this setting, as you can probably guess, you can input a description of your rules that will display.

I have the following defined in a template:
Code:
var RULES = "$vboptions[ishout_rules]";
Before I go on, someone on another forum told me:
Quote:
A JavaScript error is probably occurring. Based on the limited information that I have, I would guess that this is due to the way you're loading the rules value into JavaScript. You probably have a variable definition that looks like:
Code:
var RULES = 'a
b';
...leading me to understand that I'm bringing in invalid js.

So, the contents of the ishout_rules option that are like:

...would in fact not be valid js and cause an error.


So, if I were to design a Plugin, what hook location should I use and what should it contain? Also, how would I get a custom variable to be accessible by a template?
Or, is there a way to fix the js error?


Thanks,
Mark
Reply With Quote
  #12  
Old 07-15-2012, 11:00 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, I think this should work: create a plugin using hook parse_templates and code like this:

Code:
$ishout_rules = addcslashes($vbulletin->options['ishout_rules'], "\r\n'\\");

Then in your template:

Code:
var RULES = "$ishout_rules";

This won't change the newlines to <br>, but if you are allowing html in your rules then the person writing the rules should put <br> where they want a newlines.

By the way, you asked about how to access a variable in the other thread and I'm sorry it didn't occur to me that you might have problems like this with a string.
Reply With Quote
  #13  
Old 07-15-2012, 12:37 PM
Mko's Avatar
Mko Mko is offline
 
Join Date: May 2009
Location: East Coast, USA
Posts: 60
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
OK, I think this should work: create a plugin using hook parse_templates and code like this:

Code:
$ishout_rules = addcslashes($vbulletin->options['ishout_rules'], "\r\n'\\");
Then in your template:

Code:
var RULES = "$ishout_rules";
This won't change the newlines to <br>, but if you are allowing html in your rules then the person writing the rules should put <br> where they want a newlines.

By the way, you asked about how to access a variable in the other thread and I'm sorry it didn't occur to me that you might have problems like this with a string.
Figured it out, thanks for your help!
I had to put some PHP code into the cache_templates page then modify the output in my .js file
Reply With Quote
Reply

Thread Tools
Display Modes

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 07: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.03685 seconds
  • Memory Usage 2,187KB
  • Queries Executed 13 (?)
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
  • (6)bbcode_code
  • (3)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
  • (1)pagenav_pagelink
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)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_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete