2

I have a small question. I have included a wordpress blog on my magento shop via the fishpig module. This works great but what I want to include are header options via static cms blocks on the blog. I think I need to adjust something in the phtml of the homepage blog. app/design/frontend/base/default/template/wordpress/homepage.phtml

This is the current code:

<div class="page-title blog-title <?php if (!$this->isFirstPage()): ?>not-<?php endif; ?>first-page<?php if ($this->isFirstPage() && $this->getTagLine()): ?> with-tagline<?php endif; ?>">
<h1><?php echo $this->escapeHtml($this->getBlogTitle()) ?></h1>
</div>
<?php if ($this->isFirstPage() && $this->getTagLine()): ?>
<p class="blog-desc blog-tag-line"><?php echo $this->escapeHtml($this->getTagLine()) 
?></p>
<?php endif; ?>
<div class="blog-home">
<?php echo $this->getPostListHtml() ?>
</div>

I played arount with the following line of code but I cant get it to work:

echo $this->getLayout()->createBlock('cms/block')->setBlockId('example_block')->toHTML();   

Any solution would be great!!

Thanks..

1
  • Hello @user1773585, welcome on SO. Could you please give a more detailed description of what is not working or where a problem occurs? You code above seems to me, that you are accessing WP-method in a Magento way; what is $this in the above example? Commented Oct 25, 2012 at 9:33

1 Answer 1

1

You can display static blocks on the blog page using this code

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('example_block')->toHTML();?>

But first you need to create a static block in the admin panel. Admin-> Cms-> Static blocks. Then, after you have specified for the static block title, identifier, status and content, you'll need to replace the block identifier in your code to the identifier of the block that you created in the admin.

For example, you have created a block with identifier "blog_header" means the code to show this block on frontend, will be the

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('blog_header')->toHTML();?>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the replies. Questions here are really being answered:) Ive added the below line to the phtml file and created the static CMS BLOCK (identifier “block_header”) in the backend. Unfortunately with no luck. <div class="block_header <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('block_header')->toHTML();?> </div> Also cleared the cache but magento still doesn’t want to show the CMS block??

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.