The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
htmlentities-ish behavior when posting from a script
Hi-
I am trying to add a post from a custom script. In these posts I want to allow links to images on other websites and to have the HTML code contained in the post honored without setting the "Allow HTML" option for the forum in question to "Yes". IOW, when you post via the vB quick reply or advanced webpage, it allows you to enter links to other websites for pictures, etc. Then when you View -> Source of that result from your browser, you see this: HTML Code:
the trend is sure<br /> catching up, my cousin shot a picture of this in my town recently <br /><br /> <p><img src="http://somewebsite/blah/blah/blah.jpg" /> </p><br /> <a href="http://somewebsite.com/" rel="nofollow" class="external">http://somewebsite.com/</a> HTML Code:
<br />the trend is sure<br /> catching up, my cousin shot a picture of this in my town recently <br /><br /> <p><img src="http://somewebsite/blah/blah/blah.jpg" /> </p><br /> <a href="http://somewebsite.com/" rel="nofollow" class="external">http://somewebsite.com/</a> Code:
<br />the trend is sure catching up, my cousin shot a picture of this in my town recently <br /> <p><img src="http://somewebsite/blah/blah/blah.jpg" /> </p> <a href="http://somewebsite.com/" rel="nofollow" class="external">http://somewebsite.com/</a> So ... anyone know how to prevent this behavior when creating a post from a script without enabling "Allow HTML" via the admincp? I know it can be done because I have that option turned off right now and I get the results shown above. Thanks! |
#2
|
|||
|
|||
How is your script adding a post? You're saying that the text you're posting doesn't have the entities in it, then you do something to make it a post and it comes out with the entities?
|
#3
|
|||
|
|||
Hi kh99-
Thanks for replying. This is what I have for adding a post to an existing thread, but I get the same result regardless of whether or not I use the vB_DataManager_Post or the vB_DataManager_Thread_FirstPost object. PHP Code:
EDIT: I forgot to mention that I tried running the script both with the "Allow HTML" option set to "Yes" and with it set to "No". Either way produces the same result. The thought I originally had (which was a guess as I'm still new to vB) was that if the post was added when the "Allow HTML" option setting was "Yes" then the content would not be converted via htmlentities and stored in the DB just as you'd want it. And with that option set to "No", then you would have your HTML in your content converted and stored in the DB in that manner. To test that theory, I would set "Allow HTML" to "Yes" then run the script. Then change the setting to "No" and run the script again. As I mentioned, I got the same result. So much for that theory... Thanks! --------------- Added [DATE]1304821978[/DATE] at [TIME]1304821978[/TIME] --------------- UPDATE: I found some reference to converting to BB code in newreply.php, so I am going to look into that. Could it be that I simply need to wrap BB tags around the HTML code and that would take care of it? Boy but that would be great if it turns out to be that simple... |
#4
|
|||
|
|||
Yeah, I was going to say that I don't think you can format a post using HTML if you have "Allow HTML" set to no, it has to be bbcode. If you set allow html to yes, post some html, then set it back to no it will just show the tags instead of formatting it (which means you can't just put HTML in a post in the db). So you'll probably have to convert your post to bbcode somehow. ETA: well, I guess what I should say is that I'm not sure if it can be done. It's possible that there's a field in the db somewhere that says what kind of data is in the pagetext field that would allow it to work.
Also, there's a function called htmlspecialchars_uni() that's the equivalent to htmlentities you mentiond, it's called in a lot of places. Other than that, I think you thanked me too soon because I thought I had an idea of what might be going on, but now I don't know. I'll keep looking at it...EDIT: great, glad you got it working. |
#5
|
|||
|
|||
FINAL ANSWER:
Sure enough that was the key. By simply making a call into the wysiwyg functions and exchanging the HTML tags for BB equivalents, everything works as expected. I realize that this is true only because the forum in which this post is being made allows BB code. If that option was switched off, then naturally it wouldn't render the page as expected. However vB discourages use of HTML tags - and for good reason - not BB codes, so I'll adhere to that recomendation. BTW, here was the line of code that made the difference. This was located outside my function shown above, in a data prepare step. No other changes made to my function: PHP Code:
PHP Code:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|