|
User_Notes_simplemachines
notes about integration with the simplemachines forum platform
Phase-Deploy simplemachines forum platform integrationUsers of simplemachines based forums can integrate the pgn4web chessboard just by adding bbcode tags to their posts, like this: [pgn] ... PGN data ... [/pgn] See for instance the pgn4web test simplemachines site (this is a test site, things might occasionally be broken), or look at the users sites gallery.
screenshot
integration guidelinesThe following procedure is has been tested with simplemachines version 1.1.11 and 2.0 (see comment below the article). The forum administrator has first to enable custom bbcodes with this custom bbcode module. The reccomended value for the HTML used for the tag is the following (for some unknown reason it works better when entered as a single line with no newlines): <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>{content}</textarea> <script type='text/javascript'> document.getElementById(pgn4webTextareaId).value = document.getElementById(pgn4webTextareaId).value.replace(/<\s*br\s*\/>/gi, ' '); 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=WdSO&dcs=LHCg&bbcs=LHCg&hm=b&hcs=lF6v&bd=c&cbcs=UJuI&ctcs=BoVy&hd=j&md=f&tm=13&fhcs=$$$$&fhs=14&fmcs=$$$$&fccs=v71$&hmcs=M___&fms=14&fcs=m&cd=i&bcs=WdSO&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 simplemachines 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 simplemachines and pgn4web are on the same domain. In case you need to install simplemachines and pgn4web on different domains, please use the following alternative value for the HTML used for the tag. Please note that this alternative solution limits the size of the PGN data to approximately 2000 characters: Alternative HTML used for the tag: <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>{content}</textarea> <script type='text/javascript'> pgnText = document.getElementById(pgn4webTextareaId).value; pgnText = pgnText.replace(/<\s*br\s*\/>/gi, ' '); height = 268; multiGamesRegexp = /\s*\[\s*\w+\s*"[^"]*"\s*\]\s*[^\s\[\]]+[\s\S]*\[\s*\w+\s*"[^"]*"\s*\]\s*/m; if (multiGamesRegexp.test(pgnText)) { height += 34; } pgnEncoded = EncodePGN(pgnText); document.write("<iframe src='" + pgn4webURL + "/board.html?am=l&d=3000&ss=26&ps=d&pf=d&lcs=WdSO&dcs=LHCg&bbcs=LHCg&hm=b&hcs=lF6v&bd=c&cbcs=UJuI&ctcs=BoVy&hd=j&md=f&tm=13&fhcs=$$$$&fhs=14&fmcs=$$$$&fccs=v71$&hmcs=M___&fms=14&fcs=m&cd=i&bcs=WdSO&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. Finally, for a better appearence of the post editor, you might want to upload the image below as /smf/Themes/default/images/bbc/pgn.gif on your server (assuming /smf is the simplemachines installation directory):
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. |

For simplemachines v2, see following discussion about the update of the required custom bbcode mod: http://www.simplemachines.org/community/index.php?topic=154997.msg2845495#msg2845495