0

我们一直在尝试在 CMS 主页上显示此块的特色图像,但到目前为止在 Magento v1.7.0.0 上使用 FishPig WP 集成扩展未成功。但是,我们成功地将博客帖子中的其他内容从指定类别中显示出来。

我们要做的是让每个帖子显示 2 张图片。剩下的很好去。每个部分都被视为一个帖子。我已将两个屏幕截图与视觉辅助说明联系起来。

我们尝试在开发站点上完成此操作的区域是: https ://devtest.eboost.com

Press部分的相关代码块是

<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个视觉辅助屏幕截图:

Screenshot#1 Screenshot#2

最好的祝福,

乔治

4

1 回答 1

1

弄清楚了...

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

于 2013-01-24T17:27:58.030 回答