![]() |
|
|
Thread Tools |
|
#1
|
||||
|
||||
|
vBulletin Custom Plugin Options - Changing Carriage Returns!
Hey again all,
I've been developing a plugin, and in the vBulletin Options for this plugin, there's a textarea where users can input a paragraph for their rules. I have this following contents in my database, which is being called:
^That is EXACTLY as it is in the database, which causes my plugin not to work. An image (just to be more clear): ![]() Now, in the database, there is no \r or \n or anything of the sort. It is exactly as I mentioned above. I'm working primarily with JavaScript (innerHTML), and need to find a way to make carriage returns be interpreted as <br /> tags and NOT as physical carriage returns. Thanks in advance for any help, Mark P.S. If someone needs the .js file, let me know ![]() No members have liked this post.
Last edited by Mko : 14 Jul 2012 at 18:50. |
||||
|
#2
|
||||
|
||||
|
you'd want to use \n for new line or (and it might be deprocated) \r for return, however \n works for me
![]() --------------- Added 14 Jul 2012 at 18:43 --------------- Just did a quick Google and found this http://www.w3schools.com/js/js_special_characters.asp
__________________
Kind regards, Simon Microsoft Office Help My Mods: Prevent Number Only Registrations, Ban Spiders by User Agent, WhoIsIp Info from any post, Insert Objects/ads anywhere using php, Floating Notice Box in Forumhome, Ban IP's Easily No members have liked this post.
|
|
#3
|
||||
|
||||
|
Originally Posted by Simon Lloyd
I might've not been clear. My apologies.
Basically, I have this following contents in my database, which is being called:
^That is EXACTLY as it is in the database. An image (just to be more clear): ![]() Now, in the database, there is no \r or \n or anything of the sort. It is exactly as I mentioned above. My question remains: is there any way to make carriage returns be interpreted as <br /> tags? No members have liked this post.
|
||||
|
#4
|
||||
|
||||
|
You might try you using str replace and replace \n (i know what you said but give it a try! or \r), like this:
--------------- Added 14 Jul 2012 at 19:54 --------------- The picture of your database shows that each character is in a seperate row?
__________________
Kind regards, Simon Microsoft Office Help My Mods: Prevent Number Only Registrations, Ban Spiders by User Agent, WhoIsIp Info from any post, Insert Objects/ads anywhere using php, Floating Notice Box in Forumhome, Ban IP's Easily No members have liked this post.
|
||||
|
#5
|
||||
|
||||
|
Originally Posted by Simon Lloyd
Didn't work, sadly. Thanks though!
&no, it's just a cell in the db program I'm using. No members have liked this post.
|
||||
|
#6
|
||||
|
||||
|
in that case do you can split string like this in js
__________________
Kind regards, Simon Microsoft Office Help My Mods: Prevent Number Only Registrations, Ban Spiders by User Agent, WhoIsIp Info from any post, Insert Objects/ads anywhere using php, Floating Notice Box in Forumhome, Ban IP's Easily No members have liked this post.
|
||||
|
#7
|
||||
|
||||
|
Originally Posted by Simon Lloyd
Still no success.
I had an idea though. Regarding vB Templates, when they're saved, they don't print each carriage return. So, does anyone know how they do it? ![]() No members have liked this post.
|
||||
|
#8
|
||||||||
|
||||||||
|
Try this:
Where $option is the string from the database, and $string is what you'll use in your template for the js variable, in single quotes, like:
This assumes that what's being entered and saved in the db is not html. If it is, you don't want the htmlspecialchars() in there (and then they really should be entering the <br> tags themselves, but that's OK). Edit: Another thought - you could allow bbcode markup, and then when you pass it through the bbcode compiler it will change \n to <br>. The templates are html, so you'd have to explicitly use <br> where you wanted them in the output.
__________________
Please don't PM me - post your questions in the appropriate forum.
Please don't PM me to ask me to read your thread. No members have liked this post.
Last edited by kh99 : 14 Jul 2012 at 21:36. |
||||||||
|
#9
|
||||||||||||||||
|
||||||||||||||||
|
Originally Posted by kh99
So close, but yet it doesn't work. :/
Basically, if I've still been unclear, I'm calling the variable (which I declare in a template):
Into my .js file:
So, my problem is basically how do I manipulate the input in the ACP in JavaScript and not in PHP? No members have liked this post.
Last edited by Mko : 14 Jul 2012 at 22:42. |
||||||||||||||||
|
#10
|
||||
|
||||
|
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?
__________________
Please don't PM me - post your questions in the appropriate forum.
Please don't PM me to ask me to read your thread. No members have liked this post.
|
|
#11
|
||||||||
|
||||||||
|
Originally Posted by kh99
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:
Before I go on, someone on another forum told me:
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 No members have liked this post.
Last edited by Mko : 15 Jul 2012 at 10:34. |
||||||||
|
#12
|
||||||||
|
||||||||
|
OK, I think this should work: create a plugin using hook parse_templates and code like this:
Then in your template:
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.
__________________
Please don't PM me - post your questions in the appropriate forum.
Please don't PM me to ask me to read your thread. No members have liked this post.
|
||||||||
|
#13
|
||||||||
|
||||||||
|
Originally Posted by kh99
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 ![]() No members have liked this post.
|
||||||||
![]() |
«
Previous Thread
|
Next Thread
»
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
| Thread Tools | |
|
|
| New To Site? | Need Help? |
All times are GMT. The time now is 06:23.







