开发者

Building side navigation menu from XML file in Rails 3

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"开发者_如何学Go 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.


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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜