Skip to content

Components configuration

Valentin Ballestrino edited this page Feb 4, 2015 · 7 revisions

To display your components in the admin panel, you must define them in the config/components.rb file generated when you ran the install generator.

An example configuration is given in the components.rb file.

Enabling a component in the admin navigation

First, you need to create your component, see (Creating components)[https://github.com/para-cms/para/wiki/Creating-components] for more informations.

Say you created a CRUD component for managing a Page resource.
You'll want it to be in some "Main menu" section, and call it "Pages".
You need to define the following in the config/components.rb file :

section :main_menu do
  component :pages, :crud, model_type: 'Page'
end

This will first look for a section instance with a "main_menu" identifier. If it can't find it, it will create it.
Then, it will look for a component instance of type with an identifier of "pages".
If it exists, it will update it with the given options.
If it does not exist, it will create it and add it to the parent section.

Display ordering

Sections and components have a :position field in their table, and is filled with their index as the parser finds them.

In the previous example, both component and section would have the position: 0 set.

When you have multiple components, each time the parser is re-run (at the start of the application), their position are updated. Meanining that changing their order in the config/components/rb file and restarting the application will update their position.

section :main_menu do
  component :configuration, :singleton_resource, model_type: 'Configuration' # position is set to 0
  component :pages, :crud, model_type: 'Page' # position is set to 1
end

Would display in the menu :

  • Main menu
    • Configuration
    • Pages

Translating component names

Deleting old components

Clone this wiki locally