Class: DcDesign

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Timestamps
Defined in:
app/models/dc_design.rb

Overview

Mongoid::Document model for dc_designs collection.

Designs are essential parts of DRG CMS. Every DcPage document must have its design document defined. If DcPage documents are anchors for url addresses, DcDesign documents define how will page data be rendered in browser.

DcDesign documents define what would normally be written into Rails view file. The code is saved in the body field of DcDesign document. If you prefere Rails way, enter view file name into rails_view field and put your code into file into views directory (ex. designs/home_page for ../views/designs/home_page.html.erb file).

If you choose to save code to Rails view file you must add one top and bottom line to every source file. Top line will provide CMS edit menu, bottom line will provide additional CSS and javascript code scooped when renderers are called.

Example (as written in body of dc_design):

<div id="site">
  <div id="site-top-bg">
    <div id="site-top"><div id="logo"><%= dc_render(:dc_piece, name: 'site-top') %></div>
      <div id="login"><%= dc_render(:common, method: 'login') %></div>
   </div>
    <%= dc_render(:dc_menu, name: 'test-menu') %>
  </div>

  <div id="page"><%= dc_render(:dc_page) %></div>
</div>
<div id="site-bottom"><%= dc_render(:dc_piece, name: 'site-bottom') %></div>

Example (as written in Rails view file):

<!-- Pay attention on lines added at the top and bottom of file -->
<%= render partial: 'cmsedit/edit_stuff' if session[:edit_mode] > 0 %>

<div id="site">
  <div id="site-top-bg">
    <div id="site-top"><div id="logo"><%= dc_render(:dc_piece, name: 'site-top') %></div>
      <div id="login"><%= dc_render(:common, method: 'login') %></div>
   </div>
    <%= dc_render(:dc_menu, name: 'test-menu') %>
  </div>

  <div id="page"><%= dc_render(:dc_page) %></div>
</div>
<div id="site-bottom"><%= dc_render(:dc_piece, name: 'site-bottom') %></div>

<style type="text/css"><%= @css.html_safe %></style><%= javascript_tag @js %>

Class Method Summary collapse

Class Method Details

.choices4_designObject

Return choices for select for design_id



94
95
96
# File 'app/models/dc_design.rb', line 94

def self.choices4_design
  all.sort(name: 1).inject([]) { |r,design| r << [ design.description, design._id] if design.active; r }
end