2013-03-01 58 views
1

我正在開發擴展並希望在擴展後端頁面上顯示圖像。我在我的擴展程序的「圖像」文件夾中存儲了圖像。 我正在嘗試使用<img>標記顯示圖像。我在「src」屬性中提供了圖片url,但是它在後端頁面沒有顯示圖片。 在system.xml,我使用下面的代碼: -在magento擴展後端中顯示圖像

<myOption translate="label"> 
    <label>My Label</label> 
    <frontend_type>radios</frontend_type> 
    <source_model>mymodule/source_buttons</source_model> 
    <sort_order>30</sort_order> 
    <show_in_default>1</show_in_default> 
    <show_in_website>1</show_in_website> 
    <show_in_store>1</show_in_store> 
</myOption> 

守則Model\Source\Buttons.php文件: -

<?php 
class mycompany_mymodule_Model_Source_Buttons 
{ 
    public function toOptionArray() 
    { 
     $result = array(); 
     $result[] = array('value' => '32', 'label'=>'<img src="'.Mage::getModuleDir('', 'mycompany_mymodule').DS.'Skin'.DS.'Images'.DS.'img32.png" />'); 
     $result[] = array('value' => '16', 'label'=>'<img src="'.Mage::getModuleDir('', 'mycompany_mymodule').DS.'Skin'.DS.'Images'.DS.'img16.png" />'); 

     return $result; 
    } 
} 

在擴展後臺頁面,其顯示: -

<img src="C:\wamp\www\magento\app\code\community\mycompany\mymodule\Skin\Images\img32.png"> 

src屬性值鏈接到: -

http://mydomain/magento/index.php/admin/system_config/edit/section/mymodule_options/key/b834efa05ef37070c94d28c6b44e4bf0/C:/wamp/www/magento/app/code/community/mycompany/mymodule/Skin/Images/img32.png 

請幫助...

+1

你能展示一下你的php代碼和html輸出嗎? – dagfr 2013-03-01 15:05:09

+0

對不起。我應該第一次這樣做。沒關係。 – 2013-03-02 05:18:40

回答

3

試試這個:

echo $this->getSkinUrl(); 

你可以得到一個路徑圖像。

+0

請參閱最新的查詢。 – 2013-03-02 05:19:50

+0

您是否爲後端和前端命名了同名皮膚? – 2013-03-02 05:46:50

+0

Mage :: getDesign() - > getSkinUrl('path/images.jpg',array('_ area'=>'frontend'))嘗試將_area設置爲後端 – 2013-03-02 05:48:21