Custom CredoImage template is used to attach a caption to each image.
authorMike Taylor <mike@indexdata.com>
Wed, 21 May 2014 14:45:33 +0000 (15:45 +0100)
committerMike Taylor <mike@indexdata.com>
Wed, 21 May 2014 14:45:33 +0000 (15:45 +0100)
Unfortunately, this breaks the float-clearing styles. Darn.

Also, clicking on images goes to their site instead of doing a
regular-ass MKWS full-record popup.

examples/htdocs/mkws-widget-credo.js

index 46e9d29..d6ba4e7 100644 (file)
@@ -6,6 +6,19 @@
 
 mkws.registerWidgetType('Credo', function() {
   var that = this;
+
+  this.team.registerTemplate('CredoImage', '\
+      <div>\
+       <a href="{{md-electronic-url}}">\
+        {{#mkws-first md-thumburl}}\
+         <img src="{{this}}" alt="{{../md-title}}"/>\
+        {{/mkws-first}}\
+       <br/>\
+       </a>\
+       <p>{{md-title}}</p>\
+      </div>\
+');
+
   var s = []
   s.push('<table>');
 
@@ -15,8 +28,9 @@ mkws.registerWidgetType('Credo', function() {
   s.push('<td class="main">');
   s.push(section('encyclopaedia', 'Topic Page: ### title',
                  this.subwidget('Reference', { _team: 'ref' })));
+  // The Images widget needs to be in our team so we can set its template
   s.push(section('image', 'Images',
-                 this.subwidget('GoogleImage', { _team: 'img', maxrecs: 4 })));
+                 this.subwidget('GoogleImage', { maxrecs: 4, template: 'CredoImage' })));
   s.push('</td>');
 
   s.push('<td class="side">');