在 Rails 3 中从 XML 文件构建侧面导航菜单
我是 RoR 的新手,之前在 .NET 平台上工作。我们需要从 xml 文件构建主页。 xml 文件包含 3 个类别,每个类别下有 4 个菜单项。
XML 文件如下所示:
<menu id="mnusermgmt" caption="User">
<item id="server" level="1;1;1;1;1">
<caption>Users</caption>
<url>user_url</url>
</item>
<item id="mngrp" level="1;1;1;1;1">
<caption>Group</caption>
<url>group_url</url>
</item>
<item id="mnposition" level="1;1;1;1;1">
<caption>Position</caption>
<url>position_url</url>
</item>
<item id="mndept" level="1;1;1;1;1">
<caption>Department</caption>
<url>department_url</url>
</item>
</menu>
<menu id="msgmgmt" caption="Message">
<item id="mnmsg" level="1;1;1;1;1">
<caption>Messages</caption>
<url>messages_url</url>
</item>
<item id="mnstatistics" level="1;1;1;1;1">
<caption>Statistics</caption>
<url>Statistics_url</url>
</item>
</menu>
我使用了 application.html.erb 文件。这是代码:
"<table>
<tr>
<td class="top" width="1340px" colspan="2">
MESSAGING SYSTEM
</td>
</tr>
<tr>
<td class="name">
<div id="dvNav">
XML based Menu needs tobe build
</div>
</td>
<td class="name">
<div id="dvContent">
<%= yield %>
</div>
</td>
</tr>
</table>"
我如何使用 XML 文件构建导航菜单并链接到 application.html.erb?
问候, 苏迪尔 CN
i am newbie to RoR previously working on .NET platform. We have requirement to build a home page from xml file. The xml file cantains the 3 category and under each category we have 4 menu items.
The XML file looks like:
<menu id="mnusermgmt" caption="User">
<item id="server" level="1;1;1;1;1">
<caption>Users</caption>
<url>user_url</url>
</item>
<item id="mngrp" level="1;1;1;1;1">
<caption>Group</caption>
<url>group_url</url>
</item>
<item id="mnposition" level="1;1;1;1;1">
<caption>Position</caption>
<url>position_url</url>
</item>
<item id="mndept" level="1;1;1;1;1">
<caption>Department</caption>
<url>department_url</url>
</item>
</menu>
<menu id="msgmgmt" caption="Message">
<item id="mnmsg" level="1;1;1;1;1">
<caption>Messages</caption>
<url>messages_url</url>
</item>
<item id="mnstatistics" level="1;1;1;1;1">
<caption>Statistics</caption>
<url>Statistics_url</url>
</item>
</menu>
I have used the application.html.erb file. here is the code:
"<table>
<tr>
<td class="top" width="1340px" colspan="2">
MESSAGING SYSTEM
</td>
</tr>
<tr>
<td class="name">
<div id="dvNav">
XML based Menu needs tobe build
</div>
</td>
<td class="name">
<div id="dvContent">
<%= yield %>
</div>
</td>
</tr>
</table>"
How can i use XML file to build navigation menu and link to application.html.erb?
Regards,
Sudhir C.N.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
XML 可以通过多种方式使用。您可以在以下位置阅读一篇很好的起点文章:
http: //railstips.org/blog/archives/2008/08/11/parsing-xml-with-ruby/
祝你好运!
XML can be used in many ways. You can read a good starting point article at :
http://railstips.org/blog/archives/2008/08/11/parsing-xml-with-ruby/
Good luck!