2011-07-12 36 views
1

我試圖來填充每個第三個菜單列表的圖像/標誌我的菜單項,請在下面看到的例子。圖像插入菜單列表

enter image description here

我一直在使用Silverstripe填充菜單項,下面是我的代碼至今無圖像。有人可以請我指出正確的方向,關於如何在第三級菜單上插入圖像/徽標?

// initialise plugins 
    jQuery(function(){ 
    jQuery('ul.sf-menu').superfish(); 
    }); 

    </script> 

    <ul class="sf-menu"> 
    <% control Menu(1) %> 
    <li> 
     <a href="#a">$MenuTitle</a> 
     <% if Children %> 
      <ul><% control Children %> 
       <li> 
       <a href="#aa">$MenuTitle</a> 

        <% if Children %> 
      <ul><% control Children %> 
       <li> 
       <a href="#aa">$MenuTitle</a> 
       </li> 
       <% end_control %> 

       </ul><% end_if %> 
       </li> 
       <% end_control %> 

       </ul><% end_if %> 

    <!--<li> 
     <a href="#">menu item</a> 
    </li>--> 

     </li> <!--current--> 
    <% end_control %><!-- <li> 
     <a href="#">menu item</a> 
    </li> --> 
    </ul> <!--sf-menu--> 

感謝堆。 小號:)

更新下是我的page.php文件,我有插入$ Image.SetSize(20,20)$ MenuTitle我的第三級菜單。然而,每次我嘗試通過CMS插入圖像時,CMS中都會出現錯誤。對不起,我是新來的,任何幫助將不勝感激。

<?php 
class Page extends SiteTree { 

public static $db = array(
); 

public static $has_one = array(
     'MenuImage' => 'Image' 
); 

function getCMSFields() { 
    $fields = parent::getCMSFields(); 

    $fields->addFieldToTab("Root.Content.Images", new ImageField('MenuImage','Menu image')); 

    return $fields; 
} 
} 
    class Page_Controller extends ContentController { 


public static $allowed_actions = array (
); 

public function init() { 
    parent::init(); 

    // Note: you should use SS template require tags inside your templates 
    // instead of putting Requirements calls here. However these are 
    // included so that our older themes still work 
    Requirements::themedCSS('layout'); 
    Requirements::themedCSS('typography'); 
    Requirements::themedCSS('form'); 
} 
} 

這裏是錯誤信息。

無法運行查詢SELECT * FROM「Page」WHERE「ID」= 15表'ss_show.page'不存在 POST/Show/admin/EditForm/field/MenuImage/EditFileForm

525線在C:\ WAMP \ WWW \顯示\藍寶石\核心\型號\ MySQLDatabase.php

+0

如何在菜單中能夠獲取圖像,請幫助我即時通訊特林相同的菜單結構.... – Anudeep

+0

嗨Anudeep,我問這個問題2.5年前,對不起,我不記得確切我是怎麼做的,在時間。但是請閱讀我上面如果你正在使用Silverstripe更新(我認爲這就是我做的),它可以給你一些方向。我建議你開一個新的問題來指出你的問題,有人可能能夠進一步幫助你。 – grumpypanda

回答

0

我想通了與soneone的幫助。以防其他人處於相同的情況,這是因爲我沒有重建我的數據庫。訪問mysite.com/dev/build重建數據庫。之後的更新中的代碼工作。感謝大家! :)

+0

恭喜修復!確保接受你的答案,以便其他人可以從你的解決方案中學習。乾杯〜 –

1

假設你有你的頁面對象上的圖像,你可以做這樣的事情呈現在您的模板這樣的:

$ MyImage.SetWidth(50)$ MenuTitle

「$ MyImage.SetWidth(50)」,將輸出與圖像的圖像標籤的大小調整爲50像素寬。有關更多信息,請參閱SilverStripe image reference

+0

嗨謝恩,非常感謝你的提示。我設法在Silverstripe中插入一個圖像選項卡,但每次我嘗試上傳圖像時,上面的錯誤都顯示在CMS中。上面更新了我的Page.php。我是新來的,所以你的任何幫助將不勝感激。 – grumpypanda