If you missed the Unconference at Magento Imagine, I’ve posted my slides, as well as recorded a full screencast of the demo portion of my presentation on the Widgets feature. It’s a two parter, available on YouTube, or embedded below.
During the Q&A I got a question from Boris (of Unirgy fame). I’d been advocating hard that developers make all Blocks intended for end users Widgets. Boris pointed out that doing that means adding an interface like this
class Unconference_Youtubewidget_Block_Youtube extends Mage_Core_Block_Template implements Mage_Widget_Block_Interface
Because of this, you’d be rendering your Blocks unusable in Magento 1.3. Having some time to think about it now, I’d say a better approach would be to keep your blocks as they are
class Unconference_Youtubewidget_Block_Youtube extends Mage_Core_Block_Template
but then provide an extra block that does nothing but extend your block, and
implements the widget interface
class Unconference_Youtubewidget_Block_Youtube_Widget extends Unconference_Youtubewidget_Block_Youtube implements Mage_Widget_Block_Interface
Another nerdy question/comment came from Jay (of Sweet Tooth) fame. He pointed out you can avoid some of the Widget’s cache invalidation issues by making sure you set a cache key in your Block by issuing something like
from the Block’s
_construct pseudo constructor method. This will take care of Block caching, but inserting new Widget Instances will still invalidate your layout cache. Widgets insert Layout Update XML into the database, which gets read in when the Package Layout is created. This means a cached layout won’t get your widget updates, and you’ll need to clear it out. (At least, I think so. The nitty gritty details of the caching engine are one of those systems I haven’t much explored)
Imagine was great, and I’ve got a few more posts percolating about the conference. Beyond the official conference, the gathering of all the independent third party developers was the real conference for me. It’s going to be an interesting year in Magento land and that, more than anything else, makes me glad I picked it as a platform.