简体   繁体   English

使用ComfortableMexicanSofa和Foundation从页面创建导航

[英]Creating navigation from pages with ComfortableMexicanSofa and Foundation

I'm building my first web application using Ruby on Rails (v4.1.5) , ComfortableMexicanSofa (v1.12.2) for CMS features and admin interface and Foundation 5 for the front-end. 我正在使用Ruby on Rails(v4.1.5)构建我的第一个Web应用程序,使用适用于CMS功能的ComfortableMexicanSofa(v1.12.2)以及用于前端的管理界面和Foundation 5

To set up Foundation for Rails, I followed this guide , which created the files _navigation.html.erb and _navigation_links.html.erb in /app/views/layouts , amongst other files. 要设置Foundation for Rails,我遵循了本指南该指南/app/views/layouts创建了文件_navigation.html.erb_navigation_links.html.erb ,以及其他文件。

In the official documentation for ComfortableMexicanSofa, there is this brief guide on how to create a navigation menu from CMS pages . 在ComfortableMexicanSofa的官方文档中,有关于如何从CMS页面创建导航菜单的简要指南 Unfortunately, due to lack of experience, I'm not able to comprehend it. 不幸的是,由于缺乏经验,我无法理解它。

Relevant excerpt from the documentation: 文件中的相关摘录:

Generally you would have something like this in your helper/partial: 一般来说,你的helper / partial会有这样的东西:

 - @cms_site.pages.root.children.published.each do |page| = link_to page.label, page.full_path 

Then you can use that from the application layout, or CMS layout/page via a tag. 然后,您可以通过标签使用应用程序布局或CMS布局/页面中的内容。

To my understanding, I need to create some kind of helper in /app/helpers , where I need to to retrieve the CMS pages and serve them to my view, but I'm not sure how to implement this cleanly with Foundation. 据我所知,我需要在/app/helpers创建一些/app/helpers ,我需要检索CMS页面并将它们提供给我的视图,但我不确定如何使用Foundation实现这一点。

Any advice and examples that could point me in the right direction would be greatly appreciated. 任何可以指出我正确方向的建议和例子都将不胜感激。

You could put something like this in a view or partial: 你可以在视图或部分中放置这样的东西:

  <nav class="navbar navbar-default" role="navigation">
    <ul class="nav navbar-nav">
      <li><%= link_to 'Home', '/' %></li>
      <% Comfy::Cms::Site.first.pages.root.children.published.each do |page| %>
        <li><%= link_to page.label, page.full_path %></li>
      <% end %>
    </ul>
  </nav>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM