New Utilities section details Pogwatch tools and techniques

22 Jul 2009 MODx

Pogwatch now has a Utilities section, giving details of plugins, snippets, tools and techniques used to produce the documentation pages.

The first two features describe a plugin that helps to display the text of MODx placeholders and other elements that would normally be parsed or come out as blanks, and a wrapper snippet that displays the text of a snippet call above its result. These are used extensively in the Ditto section. Thanks to Susan Ottwell for the simple explanation of how plugins work, and to Shane Sponagle for the low-down on wrapper snippets.

Point to note if you start making plugins: the code is not wrapped in <?php and ?>, unlike snippets. Banged my head against the wall for quite a while with that one, until I found a relevant forum post.

A tool I've used in the Utilities section is GeSHi (Generic Syntax Highlighter), to produce syntax highlighting in listings of PHP scripts. I've always wondered how those pretty colours were produced in the forum [code] sections, and a little research led to the built-in PHP functions highlight_string() and highlight_file(). A little further research led to some shortcomings, and then to GeSHi, which is very adaptable and can deal with a variety of languages.

The listings necessitate a lot of SPAN tags as colour switches repeatedly, so I have set them to use an external CSS file, to avoid masses of in-line style definitions. Files in the Utilities folder have a template variable called listing, and the style sheet is included in the standard site template's HEAD section when listing is set. This is achieved using PHx: [+listing:is=`1`:then=` ... stylesheet link ... `+]


Comments (1)

kp52
Posts: 1
Comment
new comment
Reply #1 on : Thu July 23, 2009, 14:01:35
Next day: started working on presenting PubKit listings, and tried Geshi with a listing of the main snippet code on the live server. Disaster! "Compilation failed: unrecognized character after (?< at offset 3" in line 2132.
This doesn't happen looking at the same file on my PC installation, with PHP version only fractionally ahead of the live site (5.2.9-2 vs 5.2.1), so it may be some Windows/Linux thing.
Someone's blog* pointed to a very complex regular expression in Geshi's PHP definitions file, so like them, I just commented out that bit of the php.php file (lines 1080-1101), without serious impact on the quality of the listing.
PubKit's public launch has inched closer.
(*http://mitcho.com/blog/how-to/fixing-geshi-on-line-2132/)
Last Edit: July 23, 2009, 14:06:12 by bodmin  

Write a comment

  • Required fields are marked with *.

If you have trouble reading the code, click on the code itself to generate a new random code.