<aside id="secondary" class="widget_wrapper13" role="complementary">
		<div id="recent-posts-4" class="popular-posts widget widget__sidebar">
			<h3 class="widget-title"><?php echo $this->__('Most Popular Post') ?></h3>
                        <div class="widget-content">
			<ul class="posts-list unstyled clearfix">
				<?php
				$recent_posts = $this->getRecentPost();
				$home_url = Mage::helper('core/url')->getHomeUrl();
				foreach ($recent_posts as $recent_post_key => $recent_post_value) {
					//$blog_url = $home_url.'blog/view/post/p/'.$recent_post_value['title_slug'].'/';

					$urlKey = $recent_post_value['title_slug'];
					$curl = Mage::getUrl('blog/view/post/p/'.$urlKey, array('_direct' => $urlKey)); 
					$cnt=Mage::getModel('blogmate/blog')->chkIfExists('index/'.$urlKey,$urlKey);
					$store_id=Mage::app()->getStore()->getId();
					if($cnt==0 && ($urlKey != ''))
					{	
						$curl1=$recent_post_value['title_slug'];
						$rewrite = Mage::getModel('core/url_rewrite');
						$rewrite->setStoreId($store_id)
						->setIdPath('index/'.$urlKey)
						->setRequestPath($urlKey)
						->setTargetPath('blog/view/post/p/'.$urlKey)
						->setIsSystem(true)
						->save();

					}
					$blog_url =$curl; 
					?>
					<li>
						<h4><a href="<?php echo $blog_url;?>" title="<?php echo ucfirst($recent_post_value['title']);?>"><?php echo ucfirst($recent_post_value['title']);?></a></h4>
					</li>
					<?php
				}
				?>
			</ul>
                        </div> <!--widget-content-->
		</div>
		<div id="categories-2" class="popular-posts widget widget__sidebar blog_cat"><h3 class="widget-title"><?php echo $this->__('Categories') ?></h3>		
			<div class="widget-content"><?php echo Mage::helper('blogmate')->getcattree(0);?></div>
		</div>
                  <!-- Banner Ad Block -->
                  <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('amaze_blog_banner_ad_block')->toHtml() ?>
                  <!-- Banner Text Block -->
                  <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('amaze_blog_banner_text_block')->toHtml() ?>
		
	</aside>