« Back to blog

Blog: CakePHP Syntax Shot Down

Graham Weldon

01 November, 2008

It lasted almost 24 hours. You have to give it credit, thats a record breaking short lifespan for a generic helper. The CakePHP Syntax Highlighting helper that I created last night has been deemed somewhat less than useful. While its operation is clean, conforming to standards and working well, its not practical for the situation I had in mind. That being the inclusion of code blocks in blog posts.

Blog posts can be done in a number of ways. The method I prefer is the plain xhtml textarea using markdown, or a very slim CMS that allows bullet points, and maybe bold. One thing is certain for any blog entry that needs to utilise code blocks: The majority of the time the blog post content will contain code blocks and non-code blocked content. Thus, parsing becomes an issue, as we really want to parse the complete page on render, or onload, to look for markdown tags, and apply styling as necessary.

This is starting to look more like a Javascript appropriate solution. I;ve seen and been recommended Javascript solutions for achieving this, but was pretty determined to find a server side PHP based solution for blog based content. However, I can see how Javascript would be of an advantage in this case.

I might end up releasing the helper anyway, it would be useful to anyone thats storing sections of code in a database, and can completely capture the code sample separated from any other content text, to be sure no errors would be encountered.

So, not a total waste but not immediately solving the syntax highlighting issue for this site... We'll see what genius I can devise tonight!

Comments