View Full Version : Preview Help
GoOgLe
03-25-2007, 04:09 PM
how can i preview bbcodes in ams web object ???
RizlaUK
03-25-2007, 04:42 PM
you will need to translate it in to html, like the fourm software dose
heres a link to a tool that can help with the tag conversion
http://hometown.aol.co.uk/JRMC137/BBCode2HTML/index.htm
and look up string.replace in the manual, eg:
strText = String.Replace(strText, "{LEFT}", "<p align=left>", false);
strText = String.Replace(strText, "{/LEFT}", "</p>", false);
GoOgLe
03-25-2007, 04:49 PM
strText = String.Replace(strText, "{LEFT}", "<p align=left>", false);
strText = String.Replace(strText, "{/LEFT}", "</p>", false);
where will i use the string.raplace code ??? on button click of preview button or somewhere else ???
RizlaUK
03-25-2007, 04:55 PM
on button click of preview button
yup, then write the string to a temp html file and preview it in the browser
GoOgLe
03-25-2007, 05:00 PM
strText = String.Replace(strText, "", "<p align=left>", false);
strText = String.Replace(strText, "", "</p>", false);
result = Input.GetText("Input1");
TextFile.WriteFromString("C:\\temp_preview.html", "<HTML>"..result.."</HTML>", false);
File.OpenURL("C:\\temp_preview.html", SW_SHOWNORMAL);
so if i have that code in preview button what else i have to do to convert "", "" to "<p align=left>", "</p>" ????
do i have to add anything to "C:\\temp_preview.html" ???
RizlaUK
03-25-2007, 05:18 PM
you have nothing there calling the string.replace
1st, you get the text from the input
2nd, you translate the bbcode to html
3rd, you write the translated text to the html file and preview it
like this
strText = Input.GetText("Input1");-- get the text
strText = String.Replace(strText, "", "<p align=left>", false);-- translate
strText = String.Replace(strText, "", "</p>", false);-- translate
TextFile.WriteFromString("C:\\temp_preview.html","<HTML>"..strText.."</HTML>",false);-- write the html file
File.OpenURL("C:\\temp_preview.html", SW_SHOWNORMAL);-- show the preview
GoOgLe
03-25-2007, 05:23 PM
thanks Rizlauk i got it
another question what will i do for ???
GoOgle
GoOgle
GoOgLe
RizlaUK
03-25-2007, 06:12 PM
do the same
strText = String.Replace(strText, "[color=", "<font color=", false);
but the last 2 should be like this to pick up on the tags that have been missed
strText = String.Replace(strText, "[", "<", false);
strText = String.Replace(strText, "]", ">", false);
GoOgLe
03-26-2007, 12:58 AM
thanks Rizlauk
can also help me with the ordered and unordered please ???
<ol>
<li>GoOgLe</li>
</ol>
<ul>
<li>GoOgLe</li>
</ul>
that works fine for ordered but what will i do for unordered ????
strText = String.Replace(strText, "", "<ol>", false);-- translate
strText = String.Replace(strText, "", "</ol>", false);-- translate
strText = String.Replace(strText, " ", "<il>", false);-- translate
GoOgLe
03-26-2007, 01:14 AM
i managed it but please correct me if i am wrong...
strText = String.Replace(strText, "", "<ul>", false);-- translate
strText = String.Replace(strText, "/LIST]", "</ul>", false);-- translate
strText = String.Replace(strText, " ", "<li>", false);-- translate
strText = String.Replace(strText, "[list=1]", "<ol>", false);-- translate
strText = String.Replace(strText, "", "</ol>", false);-- translate
strText = String.Replace(strText, " ", "<il>", false);-- translate
GoOgLe
03-26-2007, 01:50 AM
$myvar = 'Hello World!';
for ($i = 0; $i < 10; $i++)
{
echo $myvar . "\n";
}
can u help with that please ???? what's the convertion of this code in html ???
strText = String.Replace(strText, "[ php]", "<? ", false);-- translate
strText = String.Replace(strText, "[ /php]", " ?>", false);-- translate
NOTICE: Remove space in the [ php] tag in your coding... the board is confused with this code in my post.
GoOgLe
03-26-2007, 03:03 AM
thanks alot blue
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.