我正在尝试在第三个菜单列表中的每一个上使用图像/徽标填充我的菜单项,请参见下面的示例。
我一直在使用 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 Table 'ss_show.page' 不存在 POST /Show/admin/EditForm/field/MenuImage/EditFileForm
C:\wamp\www\Show\sapphire\core\model\MySQLDatabase.php 中的第 525 行