【发布时间】:2011-07-12 05:16:12
【问题描述】:
我正在尝试在第三个菜单列表中的每一个上使用图像/徽标填充我的菜单项,请参见下面的示例。
我一直在使用 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-->
非常感谢。 S:)
UPDATE 下面是我的 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
C:\wamp\www\Show\sapphire\core\model\MySQLDatabase.php 中的第 525 行
【问题讨论】:
-
如何在菜单中获取图像请帮助我调整相同的菜单结构......
-
嗨,Anudeep,我在 2.5 年前问过这个问题,抱歉我不记得当时我是怎么做的。但是,如果您使用的是 Silverstripe,请阅读我上面的更新(我认为我就是这样做的),它可能会给您一些指导。我建议您打开一个新问题来确定您的问题,有人可能会进一步帮助您。
标签: content-management-system silverstripe