## page was renamed from DevCenter/Projects/AddViewComments = Add/View Comments = ||'''Version'''||'''Date'''||'''Changes'''|| ||1.0||2006-12-01||Initial version.|| == Want to build an Online Help Manual "livedoc" via PHP == At the bottom of each help page there should be an option to add/view comments button. === Getting Started === So there are a lot of instances where you want to add something dynamic to output created in ePublisher. In many cases you can do this with Javascript but this is a problem when you want to do something that persists across different clients. A great example would comments. It would be really nice if an API you just documented and published via ePublisher could be commented on. This way developers or engineers could add code snippets and the like to small aspects of the documentation. This could be really difficult, but with a little PHP we can make a quick comment system in no time at all. === Step One: Google PHP === There are tons of great PHP tutorials that you can look into. Also the [[http://php.net|PHP]] website has very helpful documentation that has great comments! In the comment section of the PHP website documentation you will often find code snippets that you can use as well as helpful tips that can get you past any gotchas. Also, PHP is not the only language you can use. Virtually any language can be used to make CGI scripts or accept requests. Ask around your developers/engineers and see if they have a half a day to help out making a slick comment system for the output. === Modifying the Page Template === The first step is to modify the Page.asp with the code shown in the attached [[attachment:ExamplePageAsp.zip.|ExamplePageAsp.zip]] At the very top you will notice we have removed the XML declaration () because this interferes with the PHP parsing of the page. At the very top you will also see {{{#!cplusplus }}} This is a simple PHP session that we will use to prevent against someone refreshing the page and reposting the same comment. You may also need this if you are using PHP for something such as using a user login. At the bottom of the Page Template you will see more php code: {{{#!cplusplus \n"; echo "
\n"; echo "\n"; } /* * This displays the comments by reading the comments file for the * the specific file and prints it out. */ function display_comments() { $comment_file = rtrim(__FILE__, '.php') . '.comments.txt'; if (is_file($comment_file)) { echo file_get_contents($comment_file); } } /* * Adds a comment to the comment file. * The comment file is a simple text file in the same directory as the file * * So, if the filename is MyFrameDoc.1.4.html * In ePublisher we change the extension to .php -> MyFrameDoc.1.4.php * Which makes the comment file -> MyFrameDoc.1.4.comments.txt */ function add_comment($title, $content) { // Check the session to see if this is a repost by the same user. // if ($_SESSION['comment-title'] == $title && $_SESSION['comment-content'] == $content) { return ""; } /* * Create a quick bit of HTML to save in the comment file. * There should probably be some more checking here but for now it should be ok * * WARNING: Your sys-admin will say this is a security hole. Please listen to him/her * and try to improve things. */ $new_comment_string = "