The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#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: Code:
a b 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 |
#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 [DATE]1342291426[/DATE] at [TIME]1342291426[/TIME] --------------- Just did a quick Google and found this http://www.w3schools.com/js/js_special_characters.asp |
#3
|
||||
|
||||
Quote:
Basically, I have this following contents in my database, which is being called: Code:
a b 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? |
#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:
PHP Code:
The picture of your database shows that each character is in a seperate row? |
#5
|
||||
|
||||
Quote:
&no, it's just a cell in the db program I'm using. |
#6
|
||||
|
||||
in that case do you can split string like this in js
PHP Code:
|
#7
|
||||
|
||||
Quote:
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? |
#8
|
|||
|
|||
Try this:
PHP Code:
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: Code:
var jsvar = '$jsstring'; 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. |
#9
|
||||
|
||||
Quote:
Basically, if I've still been unclear, I'm calling the variable (which I declare in a template): Code:
<script type="text/javascript"> <!-- var RULES = "$vboptions[ishout_rules]"; // --> </script> Code:
InfernoShoutbox.userframe.innerHTML = RULES; |
#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?
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|