Squidoo MDK Problems

No response from Squidoo about my countdown module yet, so I’m going to write about some problems I encoutered with the Module Development Kit. This is going to be technical and Squidoo-specific, so beware.

A bit of background : Squidoo offers a SDK for module development. This SDK (or MDK as it’s called) comes with some scarce documentation, two example modules and a “stub” module that you can use to build your own module. A basic module consists of two files – view.php and form.php. view.php is used to display the module “in action” – it might be a script that fetches and displays a RSS feed or performs some other function. form.php is used to configure the module – for a RSS module that’s where you enter the feeds’ address and specify other preferences.

The first and most frustrating glitch I discovered almost immediately was that outputting text on more than one line in view.php didn’t work. For example,

First line <br/> Second line

would work, but

First line <br/>
Second line

would generate an “Unterminated string” error in error console and display incorrectly in the browser.

The problem is that the index.php file that handles the stub module is slightly different than the index.php files for the example modules. To make ir work correctly you need to replace the 174th line that says

$('module_id1_results').innerHTML = '<?php echo addslashes($module->show()); ?>';

with this :

$('module_id1_results').innerHTML = "<?php echo str_replace("\"", "\\\"", preg_replace('/[\n\r]/', '', $module->show())); ?>";

This will make sure the output is properly escaped.

I’ve also got a minor complaint about the documentation – it states that you can add any additional JavaScript you need to view.php or form.php. That’s not true – adding a <script> block to view.php won’t work because view.php is queried with the help of AJAX and assigned to the innerHTML property of some <div>.

Another problem is that there is no documented way to execute some JavaScript function when the module is displayed (that is, when view.php is called). There is an undocumented function InitXXX() that is called after a new configuration is saved on form.php but this function is not executed when the module is first displayed. Furthermore you’d need to replace the “XXX” part with module’s ID … which appears to be unassigned for the module object in MDK. Using “1” will work for test purposes. After looking at some working modules’ output on Squidoo it looks like there is another way to get some JS executed on page load (some kind of pageLoadFunctions array) and guess what? It’s undocumented, too. And it doesn’t work in the MDK example anyway.

While the overall structure of a module might be simple, developing a more complex module can get complicated fast because documentation is insufficient (it’s 4 pages long by the way) and the Development Kit is more of a “test bench” for programmers already familiar with the specifics. “The source code is the documentation” won’t help here since we don’t have access to the complete source code.

Related posts :

One Response to “Squidoo MDK Problems”

  1. Brithney says:

    Hack again?!

Leave a Reply