Question

We have been trying to get the featured image to show for this block on CMS homepage but so far unsuccessful using FishPig WP Integration extension on Magento v1.7.0.0. However, we are successful in other content from the blog's post to show from specified category.

What we are looking to do is get 2 images to show per post. The rest is good to go. Each section is considered a post. I've linked two screenshots with explanations for visual aid.

The area on the dev site where we are trying to get this done on is: https://devtest.eboost.com

The relevant block of code for the Press section is

<div id="pressblock">
  <?php

    //$press_posts = Mage::getResourceModel('wordpress/image')->addIsPublishedFilter()->addCategorySlugFilter('press');
    $press_posts = Mage::getResourceModel('wordpress/post_collection')->addIsPublishedFilter()->addCategorySlugFilter('press');
    $presstotal = count($press_posts->getAllIds());
    $presstotid = $press_posts->getAllIds();

    //i<=2 means displays last 2 posts
    //display latest 2 posts...
    $k = 0;
    $nopages = ceil($presstotal/6);
    $pag = 1;
    for($j=$presstotal - 1; $j>=0; $j--)
      {
        $k++;
        if($k == 1)
          {
            if($pag == 1)
              {
                echo '<section id="page-'.$pag.'" class="active">';
                $pag++;
              }
            else
              {
                echo '<section id="page-'.$pag.'">';
                $pag++;
              }
          }
    ?>
        <div class="<?php if($k%2 == 0) echo 'press_right'; else echo 'press_left';?>">
          <div class="pree_emty">

            <?php
              /*
                GPSM 01-23-13:
                Some attempts to get the featured image to show. I don't see a variable to display any image really. The only thing that shows image is post_content but that shows the content as well... Maybe we can filter the image from there?

                Maybe we can use some of the code from "app/design/frontend/default/eboost/template/wordpress/post/list.phtml" or something.

                The following StackOverflow post looks to have promising suggestions:
                http://stackoverflow.com/questions/10169968/wordpress-posts-on-magento

                Check "app/code/community/Fishpig/Wordpress/Model/Image.php" for functions to display image stuff
              */
              //echo $press_posts->getItemById($presstotid[$j])->post_content;
              //print_r($press_posts->getItemById($presstotid[$j]));
              //echo $press_posts->getItemById($presstotid[$j])->getFeaturedImage();
            ?>


            <img src="<?php echo $press_posts->getItemById($presstotid[$j])->getFeaturedImage(); ?>" width="204" height="204" alt="" />
            <?php/*<img src="<?php echo $this->getSkinUrl('images/pree_emty.png');?>" width="204" height="204" alt="" />*/?>
          </div>

          <div class="press_txt">
            <h3><?php echo $press_posts->getItemById($presstotid[$j])->getPostTitle(); ?></h3>
            <p><?php echo substr(strip_tags($press_posts->getItemById($presstotid[$j])->getPostContent()), 0, 150); ?></p>
            <p><a href="#"><img src="<?php echo $this->getSkinUrl('images/viewfull_btn.png');?>" width="168" height="30" alt="" /></a></p>
          </div>
        </div>
    <?php
        if($k >= 6)
          {
            echo "</section>";
            $k = 0;
          }

      }
        if($k < 6)
          {
            echo "</section>";
          }
    ?>
  </div><!--#pressblock-->

2 screenshots for visual aid:

Screenshot#1 Screenshot#2

Best Regards,

George

Was it helpful?

Solution

Figured it out...

Essentially we pulled the custom field image from the posts. We will be making another custom field for the posts for another image. So, one image from post will be for the frontpage->press block and the second image will be displayed in a fancybox overlay.

Here is the relevant code snippet:

http://www.filedropper.com/code_1

^^ posting the code this time around screwed with the formatting and figured to just save it to a file "code.php", upload to free upload site, post here... I followed the posting instructions like last time to post the snippet but I must be doing something wrong but don't have time now to figure that out...

Regards, George

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top