Pole wyboru w Camaleon CMS
Camaleon CMS to system edytowania treści zbudowany w Ruby on Rails 4 stanowiacy alternatywę dla Wordpress. Ten cms jest bardzo łatwo rozbudowywać o własne wtyczki i komponować na własną modłę. Poniżej możesz się zapoznać z poradnikiem opisującym, jak stworzyć własne pole wyboru pozwalające na wstawianie wewnętrznych linków.
Na początek w pliku "app/apps/themes/my_theme/config/config.json" dodaj następującą linijkę
"hooks": {
....
"extra_custom_fields": ["my_theme_extra_custom_fields"]
main_helper.rb w folderze "app/apps/themes/my_theme/"
def my_theme_extra_custom_fields(args)
args[:fields][:page_picker] = {
key: 'page_picker',
label: 'Internal link',
render: theme_view('custom_field/page_picker.html.erb'),
options: {
required: false,
multiple: false,
}
}
end
Stwórz partial, w którym będzie pole select dla Twoich wewnętrznych linków
"app/apps/themes/my_theme/views/custom_field/_page_picker.html.erb"
<div class="group-input-fields-content">
<%= select_tag "#{field_name}[#{field.slug}][values][]", options_from_collection_for_select(@current_site.the_posts.decorate, "the_url", "the_url"), class: "form-control input-value #{"required" if field.options[:required].to_s.to_bool}", include_blank: true %>
</div>
I to wszystko. W kilku prostych krokach można dodać do Camaleon CMS własne pole wyboru.