2014-10-29 122 views
1

我試圖在產品頁面上添加帶有圖像的視頻,就像在4張圖像後必須顯示視頻一樣。想看產品視頻的人可以點擊視頻看視頻。爲了添加此功能,我創建了一個名爲product video的新屬性作爲文本字段,並編寫了一些代碼來擴展media.phtml。我曾嘗試在media.phtml中添加代碼,但未在輸出中進行任何更改。現在,我已經嘗試在新的phmtl文件中編寫相同的代碼,名爲video.phtml,但是在哪裏調用video.phtml文件,沒有得到確切的結果尋找。如下圖所示 鏈接是對文件: -在magento產品頁面中沒有得到正確的輸出

media.phtml

https://drive.google.com/file/d/0By64gw5ORtRjdXJfRGhHLUVJelk/view?usp=sharing

video.phtml

https://drive.google.com/file/d/0By64gw5ORtRjbGtaMWh5NC01ZEU/view?usp=sharing

在此先感謝您的幫助...

+0

'沒有得到正確的輸出',您得到的輸出是什麼以及您期望的是什麼? – Simon 2014-10-29 09:45:01

+0

沒有變化發生,但我想要4個產品圖像和第5作爲Magento產品頁面上的視頻。 – user12495 2014-10-29 09:49:17

回答

1

確保你正在編輯media.phtml文件在您當前的主題中。 另外,在驅動器中共享的media.phtml中,我看不到任何與視頻相關的代碼。

如果你想用你的video.phtml,在佈局文件的catalog.xml在主題中添加一個新的塊。

你應該把手放在手柄內catalog_product_view。您可以在媒體塊之後添加它。就像這樣:

<block type="core/template" name="product.info.video" as="video" template="catalog/product/view/video.phtml"/> <!--your video block --> 

內。然後你的產品的view.phtml,補充一點:

echo $this->getChildHtml("video"); 

我已經寫了視頻類似的模塊,你可以看看這個代碼,並建立自己的。

Video Gallery for Vzaar

+0

感謝您回覆hashid。我已嘗試video.phtml選項,但它不工作不知道什麼是我的網站的產品頁面中顯示我已經添加塊catalog.xml和添加代碼在view.phtml中,但仍然可以看到qubitinformationsystems上的輸出。 com/yoga/d-muse-women-coral-pink-top-37.html – user12495 2014-10-29 11:07:36

+0

我假設你正在編輯錯誤的地方。你能寫一個骰子嗎(「STOP THERE」);在你的phtml並檢查它的工作? – 2014-10-30 06:52:35

+0

模具()沒有被用在PHP我想?你想讓我補充哪裏? – user12495 2014-10-30 11:39:00

0

你必須要在view.phtml變化不video.phtml file.Go到文件中。

app/design/frontend/yourpackage/yourtheme/template/catalog/product/view.phtml 

查找以下代碼:這個代碼顯示了產品名稱

<div class="product-name"> 
<h1><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1> 
</div> 

插入的視頻出現在產品名稱下面的下面的代碼。

<?php if($_product->getVideo()): ?> 

<iframe width="560" height="315" src="http://www.youtube.com/embed/<?php echo $_product->getVideo() ?>" frameborder="0" allowfullscreen></iframe> 

<?php endif; ?> 

有關詳細信息,請參閱Mageno Add Video to Product

0

請使用下面的代碼:

<?php if($_product->getVideo()): ?> 

<?php endif; ?> 

,你也需要添加視頻文件中的應用程序/設計/前端/ yourpackage/yourtheme /template/catalog/product/view.phtml

使用下面的代碼添加視頻。phtml文件,那麼它會顯示產品詳細信息頁面中的視頻:

<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('templateFolderName/video.phtml')->toHtml(); ?>