2015-06-13 73 views
0

因爲我不是一個專業的程序員,所以我無法獲得ACF的集成運行的fishpig magento。 購買了FishPig-ACF附加組件和ACF Pro。 安裝了並提出名爲「中繼」的自定義字段,作爲作者日期他的手冊中描述,我將此代碼添加到/post/view.phtmlFishpig Magento集成

<?php $value = $post->getMetaValue('repeater') ?> 

所以我view.phtml看起來像這樣:

<?php 
/** 
* @category Fishpig 
* @package  Fishpig_Wordpress 
* @license  http://fishpig.co.uk/license.txt 
* @author  Ben Tideswell <[email protected]> 
*/ 
?> 
<?php $post = $this->getPost() ?> 
<?php if ($post): ?> 
<?php $helper = $this->helper('wordpress') ?> 
<?php $author = $post->getAuthor() ?> 
<div class="page-title post-title"> 
    <h1><?php echo $this->escapeHtml($post->getPostTitle()) ?></h1> 
</div> 
<div class="post-view"> 
    <p class="post-date when"><?php echo stripslashes($this->__('This entry was posted on %s<span class=\"by-author\"> by %s</span>.', $post->getPostDate(), $post->getAuthor()->getDisplayName())) ?></p> 
    <?php echo $this->getBeforePostContentHtml() ?> 
    <?php $value = $post->getMetaValue('repeater') ?> 
    <div class="post-entry entry std<?php if ($post->getFeaturedImage()): ?> post-entry-with-image<?php endif; ?>"> 
     <?php if ($post->isViewableForVisitor()): ?> 
      <?php if ($featuredImage = $post->getFeaturedImage()): ?> 
       <div class="featured-image left"><img src="<?php echo $featuredImage->getAvailableImage() ?>" alt="<?php echo $this->escapeHtml($post->getPostTitle()) ?>"/></div> 
      <?php endif; ?> 
      <?php echo $post->getPostContent() ?> 
     <?php else: ?> 
      <?php echo $this->getPasswordProtectHtml() ?> 
     <?php endif; ?> 
    </div> 
    <?php echo $this->getAfterPostContentHtml() ?> 
    <?php echo $this->getCommentsHtml() ?> 
    </div> 
<?php endif; ?> 

但是在前面的ACF沒有顯示。

THX任何幫助

+0

你會得到中繼器字段的值嗎? – saravanavelu

回答

1

你複製並粘貼下面的代碼:

<?php $value = $post->getMetaValue('repeater') ?> 

此代碼生成中繼值和變量名爲$值保存它。而已。此代碼不會對此值執行任何操作,也不會將其打印到屏幕上,因此沒有顯示任何內容是正確的。

要查看有什麼領域內,嘗試以下操作:

<pre><?php print_r($post->getMetaValue('repeater')) ?></pre> 

上面的代碼將中繼字段的值打印到屏幕上。假設您爲當前帖子的此字段設置了一個值,則此值爲包含您設置的數據的數組。然後您需要使用foreach循環遍歷數組並處理/顯示數據。

+0

好吧,這個snipppet會打印出一個字段,但遠離使用圖庫。我怎樣才能添加一個畫廊到一個頁面? – Bingo

+0

您需要遍歷中繼器字段中的數據併爲您的圖庫創建所需的HTML。然後您將添加適當的CSS規則和JS。 –

相關問題