Module: CamaleonCms::CustomFieldsConcern

Included in:
NavMenuItemDecorator, PostDecorator, TermTaxonomyDecorator, UserDecorator, WidgetDecorator
Defined in:
app/decorators/camaleon_cms/custom_fields_concern.rb

Overview

Camaleon CMS is a content management system

Copyright (C) 2015 by Owen Peredo Diaz
Email: [email protected]
This program is free software: you can redistribute it and/or modify   it under the terms of the GNU Affero General Public License as  published by the Free Software Foundation, either version 3 of the  License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the  GNU Affero General Public License (GPLv3) for more details.

Instance Method Summary collapse

Instance Method Details

#render_fieldsObject

CUSTOM FIELDS=====================================

render as html the custom fields marked for frontend


12
13
14
15
16
# File 'app/decorators/camaleon_cms/custom_fields_concern.rb', line 12

def render_fields
  object.cama_fetch_cache("render_fields") do
    h.controller.render_to_string(partial: "partials/render_custom_field", :locals => {fields: object.get_fields_object(true)})
  end
end

#the_field(field_key, default_val = '') ⇒ Object

return custom field content with key field_key translated and short codes evaluated like the content default_val: default value returned when this field was not registered


21
22
23
# File 'app/decorators/camaleon_cms/custom_fields_concern.rb', line 21

def the_field(field_key, default_val = '')
  h.do_shortcode(object.get_field(field_key, default_val).to_s.translate(@_deco_locale), object)
end

#the_field!(field_key, default_val = '') ⇒ Object

the same as the_field(..), but this return default value if there is not present


26
27
28
# File 'app/decorators/camaleon_cms/custom_fields_concern.rb', line 26

def the_field!(field_key, default_val = '')
  h.do_shortcode(object.get_field!(field_key, default_val).to_s.translate(@_deco_locale), object)
end

#the_fields(field_key) ⇒ Object

return custom field contents with key field_key translated and short codes evaluated like the content this is for multiple values


33
34
35
36
37
38
39
# File 'app/decorators/camaleon_cms/custom_fields_concern.rb', line 33

def the_fields(field_key)
  r = []
  object.get_fields(field_key).each do |text|
    r << h.do_shortcode(text.to_s.translate(@_deco_locale), object)
  end
  r
end