|
User_Notes_phpBB
notes about integration with the phpBB forum platform
Phase-Deploy phpBB forum platform integrationUsers of phpBB based forums can integrate the pgn4web chessboard in their posts using a custom bbcode for PGN games, like this: [pgn] ... PGN data ... [/pgn] See for instance the pgn4web test phpBB site (this is a test site, things might occasionally be broken), or look at the users sites gallery.
screenshot
integration guidelinesThe following procedure requires phpBB version 3 or above and has been fully tested with phpBB version 3.0.6 See generic instructions for the forum administrator to create custom bbcodes in phpBB. The forum administrator should create a new BBcode with BBcode usage string: [pgn]{TEXT}[/pgn]The reccomended value for the HTML replacement string is: <script type='text/javascript'>
var pgn4webPath = "/pgn4web";
var pgn4webTextareaIdNum;
if (pgn4webTextareaIdNum === undefined) { pgn4webTextareaIdNum = 1; }
pgn4webTextareaId = "pgn4web_" + pgn4webTextareaIdNum++;
document.write("<textarea id='" + pgn4webTextareaId +"' style='display: none;'>");
</script>
{TEXT}
</textarea>
<script type='text/javascript'>
document.getElementById(pgn4webTextareaId).value = document.getElementById(pgn4webTextareaId).value.replace(/<\s*br\s*\/>/gi, ' ');
document.getElementById(pgn4webTextareaId).value = document.getElementById(pgn4webTextareaId).value.replace(/<\s*span[^>]*>([^<]*)<\s*\/span\s*>/gi, '\$1');
height = 268;
multiGamesRegexp = /\s*\[\s*\w+\s*"[^"]*"\s*\]\s*[^\s\[\]]+[\s\S]*\[\s*\w+\s*"[^"]*"\s*\]\s*/m;
if (multiGamesRegexp.test(document.getElementById(pgn4webTextareaId).value)) { height += 34; }
document.write("<iframe src='" + pgn4webPath + "/board.html?am=l&d=3000&ss=26&ps=d&pf=d&lcs=TtKN&dcs=LHCg&bbcs=LHCg&hm=b&hcs=mF9_&bd=c&cbcs=RZmI&ctcs=zEtr&hd=j&md=f&tm=13&fhcs=$$$$&fhs=14&fmcs=$$$$&fccs=v71$&hmcs=M___&fms=14&fcs=m&cd=i&bcs=TtKN&fp=13&hl=t&fh=b&fw=p&pi=" + pgn4webTextareaId + "' frameborder=0 width=100% height=" + height + " scrolling='no' marginheight='0' marginwidth='0'>your web browser and/or your host do not support iframes as required to display the chessboard</iframe>");
</script>Please remember to set the variable pgn4webPath above to the path of the pgn4web folder on your site. Please note these settings apply a predefined set of colors and options to match the default phpBB template; if you need to change any of the colors and options (the parameters after board.html in the code above) you can refer to the board widget instructions wiki page or ask for support. The instructions above require pgn4web 1.91 or later and requires that phpBB and pgn4web are on the same domain. In case you need to install phpBB and pgn4web on different domains, please use the following alternative value for the HTML replacement string. Please note that this alternative solution limits the size of the PGN data to approximately 2000 characters: <script type="text/javascript">
var pgn4webURL = "http://pgn4web.casaschi.net";
if (!document.getElementById("pgn4webEncoderScript")) { document.write('<script id="pgn4webEncoderScript" type="text/javascript" src="' + pgn4webURL + '/pgn-encoder.js"></' + 'script>'); }
</script>
<script type='text/javascript'>
var pgn4webTextareaIdNum;
if (pgn4webTextareaIdNum === undefined) { pgn4webTextareaIdNum = 1; }
pgn4webTextareaId = "pgn4web_" + pgn4webTextareaIdNum++;
document.write("<textarea id='" + pgn4webTextareaId +"' style='display: none;'>");
</script>
{TEXT}
</textarea>
<script type='text/javascript'>
pgnText = document.getElementById(pgn4webTextareaId).value;
pgnText = pgnText.replace(/<\s*br\s*\/>/gi, ' ');
pgnText = pgnText.replace(/<\s*span[^>]*>([^<]*)<\s*\/span\s*>/gi, '\$1');
height = 268;
multiGamesRegexp = /\s*\[\s*\w+\s*"[^"]*"\s*\]\s*[^\s\[\]]+[\s\S]*\[\s*\w+\s*"[^"]*"\s*\]\s*/m;
if (multiGamesRegexp.test(document.getElementById(pgn4webTextareaId).value)) { height += 34; }
pgnEncoded = EncodePGN(pgnText);
document.write("<iframe src='" + pgn4webURL + "/board.html?am=l&d=3000&ss=26&ps=d&pf=d&lcs=TtKN&dcs=LHCg&bbcs=LHCg&hm=b&hcs=mF9_&bd=c&cbcs=RZmI&ctcs=zEtr&hd=j&md=f&tm=13&fhcs=$$$$&fhs=14&fmcs=$$$$&fccs=v71$&hmcs=M___&fms=14&fcs=m&cd=i&bcs=TtKN&fp=13&hl=t&fh=b&fw=p&pe=" + pgnEncoded + "' frameborder=0 width=100% height=" + height + " scrolling='no' marginheight='0' marginwidth='0'>your web browser and/or your host do not support iframes as required to display the chessboard</iframe>");
</script>Please remember to set the variable pgn4webURL above to the URL of the pgn4web server you plan to use.
further customizationsWith minor modifications to the integration guidelines described above other bbcode tags can be created for specialized applications, for instance taking advantage of the board widget puzzle support. |

How phpBB3 users can post chess diagram with pgn4web? I already installed pgn4web and it works well after creating custom bbcode in phpBB as explaned above. But this coad does not works with the FEN. Please guide me how my users can post chess diagrams in phpBB3 fourm. is it possible (with pgn4web)to create a custom bbcode which allow users to create a diagram and then post it in the fourm???
You can find a working example of the [pos] tag here:
http://pgn4web-test.casaschi.net/phpbb/viewtopic.php?f=2&t=3
the pgn tag defined above only understands PGN inputs; for a FEN string to be understood as PGN input, you have to supply PGN data in this format:
You can easily adapt the pgn tag above to accept FEN inputs directly, defining as BBcode usage string pos?{TEXT}[/pos] (note that there is an internal conflict if you try using fen?) and as HTML replacement the following code:
<script type='text/javascript'> var pgn4webPath = "/pgn4web"; var pgn4webTextareaIdNum; if (pgn4webTextareaIdNum === undefined) { pgn4webTextareaIdNum = 1; } pgn4webTextareaId = "pgn4web_" + pgn4webTextareaIdNum++; document.write("<textarea id='" + pgn4webTextareaId +"' style='display: none;'>"); </script> [FEN "{TEXT}"] [SetUp "1"] * </textarea> <script type='text/javascript'> document.getElementById(pgn4webTextareaId).value = document.getElementById(pgn4webTextareaId).value.replace(/<\s*br\s*\/>/gi, ' '); height = 240; document.write("<iframe src='" + pgn4webPath + "/board.html?am=n&d=3000&ss=26&ps=d&pf=d&lcs=TtKN&dcs=LHCg&bbcs=LHCg&hm=b&hcs=mF9_&bd=h&cbcs=RZmI&ctcs=zEtr&hd=j&md=f&tm=13&fhcs=$$$$&fhs=80p&fmcs=$$$$&fccs=v71$&hmcs=M___&fms=80p&fcs=m&cd=i&bcs=TtKN&fp=13&hl=t&fh=b&fw=p&pi=" + pgn4webTextareaId + "' frameborder=0 width=100% height=" + height + " scrolling='no' marginheight='0' marginwidth='0'>your web browser and/or your host do not support iframes as required to display the chessboard</iframe>"); </script>The above is the code assuming pgn4web is on your server at the "/pgn4web" path.
If you need to use pgn4web from a different server, the HTML replacement code should be:
<script type="text/javascript"> var pgn4webURL = "http://pgn4web.casaschi.net"; if (!document.getElementById("pgn4webEncoderScript")) { document.write('<script id="pgn4webEncoderScript" type="text/javascript" src="' + pgn4webURL + '/pgn-encoder.js"></' + 'script>'); } </script> <script type='text/javascript'> var pgn4webTextareaIdNum; if (pgn4webTextareaIdNum === undefined) { pgn4webTextareaIdNum = 1; } pgn4webTextareaId = "pgn4web_" + pgn4webTextareaIdNum++; document.write("<textarea id='" + pgn4webTextareaId +"' style='display: none;'>"); </script> [FEN "{TEXT}"] [SetUp "1"] * </textarea> <script type='text/javascript'> pgnText = document.getElementById(pgn4webTextareaId).value; pgnText = pgnText.replace(/<\s*br\s*\/>/gi, ' '); height = 240; pgnEncoded = EncodePGN(pgnText); document.write("<iframe src='" + pgn4webURL + "/board.html?am=n&d=3000&ss=26&ps=d&pf=d&lcs=TtKN&dcs=LHCg&bbcs=LHCg&hm=b&hcs=mF9_&bd=h&cbcs=RZmI&ctcs=zEtr&hd=j&md=f&tm=13&fhcs=$$$$&fhs=80p&fmcs=$$$$&fccs=v71$&hmcs=M___&fms=80p&fcs=m&cd=i&bcs=TtKN&fp=13&hl=t&fh=b&fw=p&pe=" + pgnEncoded + "' frameborder=0 width=100% height=" + height + " scrolling='no' marginheight='0' marginwidth='0'>your web browser and/or your host do not support iframes as required to display the chessboard</iframe>"); </script>