FishPig WordPress - Magento v1.7.0.0获取精选图片展示

时间:2013-01-24 03:26:32

标签: magento magento-1.7 fishpig

我们一直在尝试在CMS主页上显示此块的精选图片,但到目前为止在Magento v1.7.0.0上使用FishPig WP Integration扩展失败了。但是,我们成功地从博客的帖子中显示了指定类别的其他内容。

我们要做的是每个帖子显示2张图片。其余的很好。每个部分都被视为一个帖子。我已将两个屏幕截图与视觉辅助的解释相关联。

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

新闻部分的相关代码块

<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 http://s14.postimage.org/jcqrdwie9/wpcustomfield.jpg Screenshot#2 http://s9.postimage.org/dyhs0zlu7/homepage_pressblock.jpg

最诚挚的问候,

乔治

1 个答案:

答案 0 :(得分:1)

想出来......

基本上我们从帖子中提取自定义字段图像。我们将为另一个图像的帖子制作另一个自定义字段。因此,post中的一个图像将用于frontpage-&gt; press block,第二个图像将显示在fancybox overlay中。

以下是相关的代码段:

http://www.filedropper.com/code_1

^^这次发布的代码一直搞砸了格式化并想通了将它保存到文件“code.php”,上传到免费上传网站,发布在这里...我跟上发帖说明就像上次一样发布片段,但我一定做错了,但现在没有时间弄清楚......

此致 乔治