<%= @document.title %>

<%= textilize @document.summary %>
<% @document.meta_definition.children.each do |md| %>

<%= md.label.titleize.pluralize.capitalize %>

<% unless md.documents.empty? %> <% md.field_map.each do |k,v| %> <% end %> <% if md.record_hits? %> <% end %> <% documents = @document.children.by_label(md.label).order_by(md.sort_by).paginate(:per_page => 20, :page => params["#{md.label}_page".to_sym]) %> <% documents.each do |page| %> <% md.field_map.each do |k,v| %> <% end %> <% if md.record_hits? %> <% end %> <% if md.sort_by == 'position ASC' %> <% end %> <% end %>
<%= k.titleize %>Title State AuthorHits
<%= page.send(v) %><%= truncate(page.title, :length => 40) %> <% form_for page.becomes(Document), :url => admin_document_path(page.id) do |f| %> <%= f.select :state, [['Published','published'], ['Draft', 'draft'], ['Pending', 'pending']] %> <%= f.submit 'Change' %> <% end %> <%= page.author.name %><%= page.hits %> <%= link_to 'Open', admin_document_path(page.id), :class => 'button' %> <%= link_to 'Edit', edit_admin_document_path(page.id), :class => 'button' %> <%= link_to 'Up', up_admin_document_path(page.id), :class => 'button' unless page.first? %> <%= link_to 'Down', down_admin_document_path(page.id), :class => 'button' unless page.last? %> <% unless page.system? %> <%= link_to 'Delete', admin_document_path(page.id), :method => 'delete', :confirm => 'Are you sure?', :class => 'button' %> <% end %>
<%= will_paginate documents, :param_name => "#{md.label}_page".to_sym %> <% else %>

There are no <%= md.label.titleize.pluralize %> yet!

<% end %>

<%= link_to 'New ', new_admin_document_path + '?parent=' + @document.id.to_s + '&label=' + md.label, :class => 'button' %>

<% form_for md, :url => admin_meta_definition_path(md.id) do | f | %>

<%= f.select :sort_by, sort_by_options, :include_blank => true %>

<%= f.select :per_page, per_page_options, :include_blank => true %>

<%= f.submit 'Save' %> <% end %> <% end %>