1

これが私が達成しようとしていることですが、どこから始めればよいかわかりません。

次のページ構造があります。 ここに画像の説明を入力

ホームページでは、出版物の各子をセクションとして表示したいと考えています。2 つのセクションは、Alerts と New Story of the Week です。次に、セクションの最新の公開された子がそのセクション内でレンダリングされます。したがって、ホームページには次のセクションと記事があります: Alerts -> Trouble in the East-1-20-2015 News Story of the Week -> Congress Ohverhaus Farm Bill

CMS wiki を読みましたが、これにアプローチする方法がわかりません。タグとコレクションを使用しますか?

4

2 に答える 2

3

これを機能させるには、パーシャルを作成する必要があります。

ここで作成します/app/views/comfy/cms/content/_section_list.html.erb

次に、ホームページのレイアウトで、パーシャルを表示する html に追加{{cms:partial:section_list}}します。

次に、_section_list.html.erb次のようなことを行います。

<% @cms_page.children.each do |section| %>
  <h1><%= section.blocks.where(identifier: 'header').first.content %></h1>
  <%= section.children.first.blocks.where(identifier: 'content').first.content %>
<% end %>

注: 必ずブロック識別子を正しく取得してください。上記のスニペットにand があるheaderと仮定しています。content

于 2015-01-19T17:01:56.387 に答える
2

In cms layout that Publication is using define a partial tag {{ cms:partial:foo/bar/articles }}

Inside that partial you'll have access to @cms_page. Now you can render things out.

@cms_page.children will give you Alerts and News Story of the Week pages. Then you can fetch a first child of those pages.

It's using acts_as_tree in the back, so it's pretty straightforward.

于 2015-01-19T16:43:08.710 に答える