Free Email and Web Hosting for a limited time only! Find out more

Magento – AheadWorks Blog – Add blog posts to CMS pages

Magento – AheadWorks Blog – Add blog posts to CMS pages

AW Blog is a Magento extension from aheadWorks that is reckoned among the best buzz and word of mouth marketing tips. It not only provides your regular customers with up-to-date information but brings additional visitors to your site, builds relevant SEO-friendly text links, and serves as assistance in building sales strategy. The Blog extension gives you a noteworthy opportunity to communicate with your regular customers and casual visitors. With Blog you can create an interactive two-way communication platform to provide official information on your store news, upcoming products, promotions, and get customers’ feedback. Plugin is available from http://www.magentocommerce.com/magento-connect/aheadworks/extension/1516/blog-extension-by-aheadworks Adding blog Post to multiple CMS pages This mod will allow you to add blog posts from specific categories onto specific CMS pages.

Step 1

/public_html/app/code/community/AW/Blog/Block/Blog.php Change existing code to
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class AW_Blog_Block_Blog extends Mage_Core_Block_Template
{
    public function getPosts($catfilter)
        {
   
            $tag = $this->getRequest()->getParam('tag');

            if(!$catfilter) {
                $collection = Mage::getModel('blog/blog')
                    ->getCollection()
                    ->addPresentFilter()
                    ->addStoreFilter(Mage::app()->getStore()->getId())
                    ->setOrder('created_time ', 'desc');
             }
             else {
                $collection = Mage::getModel('blog/blog')
                    ->getCollection()
                    ->addPresentFilter()
                    ->addStoreFilter(Mage::app()->getStore()->getId())
                    ->setOrder('created_time ', 'desc')
                    ->addCatFilter($catfilter);
             }

Step 2

In /public_html/app/design/frontend/default/default/template/aw_blog copy blog.phtml to blog-cmspagename.phtml In the new phtml file change the first few lines
1
2
3
4
5
    $posts = $this->getPosts(3);  // 3 is the blog category id
    $limit=4;
    $i=0;
    foreach ($posts as $post):
        if ($i++ > $limit) break;

Step 3

In the admin backend, goto CMS>Page>Your Page In Content, Add
1
{{block type="blog/blog" name="blog" alias="list_blog" template="aw_blog/blog-cmspagename.phtml"}}

 

Share

11 comments on “Magento – AheadWorks Blog – Add blog posts to CMS pages

  • pradeep

    hi,

    i need blog serach and archive with date and post count !! can you please help how to implement that 2 thing in aheadwroks blog module

  • Edgard Niza

    Very useful tutorial, bookmarked !
    Thanks

  • Terrie Mrazek

    I blog often and I truly appreciate your information. This great article has truly peaked my interest. I’m going to bookmark your website and keep checking for new information about once a week. I subscribed to your RSS feed too.

  • Marquerite Senst

    May I simply say what a comfort to discover somebody who really knows what they are discussing online. You actually understand how to bring an issue to light and make it important. A lot more people ought to check this out and understand this side of the story. I was surprised that you’re not more popular since you certainly possess the gift.

  • Kevin

    Thanks for the tutorial… this has limited my main blog page to just display posts from the first category… how can I get the main blog page to display all categories?

    • Terry Ellis

      Hi Kevin,

      Try removing ->addCatFilter($catfilter);

      See if that helps.

      • Kevin

        Hi Terry, thanks for your help… this displays all the categories on the main blog page now but also on the individual cms pages where I want specific categories.

        • Terry Ellis

          Hi Kevin, I dont have a test site ‘live’ at the moment to test this, but try this…

          In step 1 (above),

          please update your code to the above (updated code).

          In step 2,

          try changing getPosts(3); to getPosts($_GET["catfil"]);

          In step 3,

          on the individual cms pages, where you need a filter, try changing template=”aw_blog/blog-cmspagename.phtml” to template=”aw_blog/blog-cmspagename.phtml?catfil=3

          • Kevin

            Hi Terry, unfortunately it’s still displaying all categories.

            Also ‘;’ is missing from the end of the following line in step 1:

            ->setOrder(‘created_time ‘, ‘desc’)

  • Terry Ellis

    Thanks Kevin, semi colon added back in.

    Try this,

    In step 3, revert back to original code (as above) and then add inline catfil=”3″ (or other cat id). Or don’t add this to display all categories.

    In Step 2, replace

    $posts = $this->getPosts(3);

    with something like

    $catfil = $this->getData(‘catfil’);
    $posts = $this->getPosts($catfil);

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Login


Social

Our Map