-
Notifications
You must be signed in to change notification settings - Fork 9
Components configuration
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.
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.
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
end