
<?php if (is_null(Mage::registry('blogId'))): ?>
    <?php echo Mage::helper('designer/messages')->error('Invalid blog id.') ?>
<?php else: ?>
    <?php $_buffer = Mage::getModel('designer/buffer') ?>

    <?php if($this->getResultCount()): ?>
        <?php echo Mage::helper('designer/messages')->all() ?>

        <?php if ($_buffer->capture('header')): ?>
            <?php if ($this->helper('rss/catalog')->getTagFeedUrl()): ?>
                <a href="<?php echo $this->helper('rss/catalog')->getTagFeedUrl() ?>" class="nobr link-rss"><?php echo $this->__('Subscribe to Feed') ?></a>
            <?php endif ?>
            <?php echo ($this->getHeaderText() || $this->getHeaderText() === false) ? $this->getHeaderText() : $this->__("Search results for '%s'", $this->helper('catalogsearch')->getEscapedQueryText()) ?>
        <?php endif ?>

        <?php if ($_buffer->capture('content')): ?>
            <?php if ($messages = $this->getNoteMessages()):?>
                <?php echo Mage::helper('designer/messages')->notice($messages) ?>
            <?php endif ?>
            <?php echo $this->getProductListHtml() ?>
        <?php endif ?>

    <?php else: ?>

        <?php if ($_buffer->capture('header')): ?>
            <?php echo ($this->getHeaderText() || $this->getHeaderText() === false) ? $this->getHeaderText() : $this->__("Search results for '%s'", $this->helper('catalogsearch')->getEscapedQueryText()) ?>
        <?php endif ?>

        <?php if ($_buffer->capture('content')): ?>
            <?php
            $messages = array($this->getNoResultText() ? $this->getNoResultText() : $this->__('Your search returns no results.'));
            if ($_notes = $this->getNoteMessages()) {
                $messages = array_merge($messages, $_notes);
            }
            echo Mage::helper('designer/messages')->notice($messages)
            ?>
        <?php endif ?>

    <?php endif ?>

    <?php
        $_blogTpl = Mage::helper('designer')->createTemplate('blog', Mage::registry('blogId'));
        $_blogTpl->setArticles($_buffer->complete());
        echo $_blogTpl->toHtml();
    ?>

<?php endif ?>
