Alchemy CMS: Create element that contains list of elements

520 views Asked by At

I'd like to create an element which can contain a list of items, where each item can have more than one essences.

For example: The user should be able to add a "page listing" as content element. For each page item he should be able to upload a small image, a short description and a link. Because the list needs to be wrapped with an UL tag, I can't simply ask him to add a lot of elements.

Other example: The user should be able to add a "team listing" as content element. Each member having a photo, a name, a job description and an email address. Same problem here: I'd like to have the team members wrapped within an DL tag.

Is there some way of releasing elements which can contain elements?

Some kind like: (just an example, might contain bugs)

- name: my_list_element
  contents:
  - name: list_style
    type: EssenceSelect
  - name: items
    type: Element ???
    elements: [my_item_element]
    settings:
      deletable: true
  available_contents:
  - name: items
    type: Element ???
    elements: [my_item_element]
    settings:
      deletable: true

- name: my_item_element
  contents:
  - name: image
    type: EssencePicture
  - name: headline
    type: EssenceText
    ...

The inner item uses the default editor for pictures or text essences.

If someone knows a way how to realize this it would be very great, because it's the last puzzle part which is missing in order to use alchemy CMS :(

Thank you in advance

3

There are 3 answers

0
tvdeyen On BEST ANSWER

You want to use the new nestable Elements feature you'll find in the current master and soon to be released 3.3 version. Unfortunately they are not well documented yet. Sorry.

But it's really simple. Instead of the available_contents (That will be deprecated in favor of nested elements anyway, you list names of nestable_elements).

A nestable element can be any element you have defined.

Unless the guides got updated, please read the documentation in the code.

0
Mike Belyakov On

You may use http://ruby-doc.org/stdlib-2.1.0/libdoc/yaml/rdoc/YAML.html and get Hash in the output and also save it in text as well

0
SkipIntro On

Hope to see nestable_elements feature soon, may be it will solve some really obvious tasks. For now, without the possibility to easy extend Alchemy with custom models (Post, TeamMember, Testimonial, PortfolioItem, etc) I am still the fan on RefineryCMS or pure RoR, and this is sad, because AlchemyCMS has really nice things built-in. As I can understand, this feature will be implemented in Alchemy 4 by Nodes, even the Page model will be registered as Alchemy::Node, and developer will be able to create own Nodes which will behave like custom_post_type in WordPress.