6
July
2005

HaloScan Hacks Part2 – Retrieving comments with PHP to add to pages.

HaloScanAfter I implemented HaloScan as a method of storing my comments for my blogs, I also wanted to add comment functionality to the Photo Gallery section of the site. I wanted a way to display these comments on the actual pages and needed to develop a hack to do this.

The hack is straight forward and simple load the contents of the comments window into a string variable and parse out the comments. HaloScans comments page is formed using tables to display the various elements so parsing it was not to difficult. I utilize the Snoopy PHP class to retrieve the comments page. Then explode the string into an array using the class identifier “MessageCell” in the HTML TD tag to split them. Simple looping through the various cells to extract the data is then a simple manner. For me I needed the comments in an XML form as they were being added as nodes to a XML document that would then be transformed to produce the page, so some additional cleanup and formatting was required.

You are more than welcome to use the code for my solution and modify it as you require.

 

Leave a comment