0

CMS ホームページでこのブロックの注目の画像を表示しようとしてきましたが、Magento v1.7.0.0 で FishPig WP 統合拡張機能を使用してこれまでのところ成功していません。ただし、ブログの投稿から他のコンテンツを特定のカテゴリから表示することに成功しています。

私たちが目指しているのは、投稿ごとに表示する 2 つの画像を取得することです。残りは大丈夫です。各セクションは投稿と見なされます。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 つのスクリーンショット:

スクリーンショット#1 スクリーンショット#2

よろしくお願いします、

ジョージ

4

1 に答える 1

1

理解した...

基本的に、投稿からカスタム フィールドの画像を取得しました。別の画像の投稿用に別のカスタム フィールドを作成します。したがって、投稿からの 1 つの画像はフロントページ -> プレス ブロック用になり、2 番目の画像はファンシー ボックス オーバーレイに表示されます。

関連するコード スニペットは次のとおりです。

http://www.filedropper.com/code_1

^^ 今回のコードの投稿は、書式設定に問題があり、「code.php」ファイルに保存し、無料のアップロード サイトにアップロードし、ここに投稿することを考え出しました... 前回と同様に投稿手順に従ってスニペットを投稿しましたしかし、私は何か間違ったことをしているに違いありませんが、今はそれを理解する時間がありません...

よろしく、ジョージ

于 2013-01-24T17:27:58.030 に答える