Magento - Getting the title of a cms static block from it's block_id?
magento
Solution
Seems the following works:
$blockid = $this->getBlockId();
$block = Mage::getModel('cms/block')->load($blockid);
echo $block->getTitle();
Always helps to write out a question here, half the time seeing it written helps me find the answer myself!
Problem
I'm inserting a cms static block via a widget instance - and I'd like to output the static block title as well as it's content, from within my widget template. The default template (app/design/frontend/base/default/template/cms/widget/static_block/default.phtml) simply has: ``` <?php echo $this->getText(); ?> ``` I changed that to getData() instead to see what it was possible to grab, which is the following: ``` [type] => cms/widget_block [block_id] => 11 [module_name] => Mage_Cms [text] => blahblahblah ``` So I'm guessing the only way is to use the block_id to get the title, but can't quite figure out how. I can grab the block_id from there with $this->getBlockId() - but then how do I use that to get the title? I thought the following might work but it doesn't: ``` $blockid = $this->getBlockId(); $blocktitle = Mage::getModel('cms/page')->load($blockid, 'block_id')->getTitle(); ```