Skip to content

Commit aeee121

Browse files
authored
field groups in Fluid (#522)
* field groups in Fluid * Update fluid.md * update to use field group short names * no message
1 parent 550b3c3 commit aeee121

File tree

2 files changed

+90
-3
lines changed

2 files changed

+90
-3
lines changed

docs/control-panel/field-manager/field-manager-settings.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,15 @@ Fields have the following settings:
4040

4141
**Control Panel Location: `Developer > Fields > Field Groups > New/Edit Field Group`**
4242

43-
This section allows you to create and edit field groups. Field Groups are collections of fields which can then be related to one or more [Channels](control-panel/channels.md#fields-tab).
43+
This section allows you to create and edit field groups. Field Groups are collections of fields which can then be related to one or more [Channels](control-panel/channels.md#fields-tab) as well as used in [Fluid fields](fieldtypes/fluid.md).
44+
45+
The field group details and assigned fields can be edited by clicking pencil icon next to field group name.
46+
47+
Clicking on the group name will show the list of fields assigned to this group.
48+
49+
Fields groups have following properties:
50+
51+
- **Name** -- Name of field group displayed in Control Panel
52+
- **Short Name** -- The short name of field group, used in Fluid fields when looping through the group's fields
53+
- **Description** -- Description of field group
54+
- **Fields** -- The fields can be reordered by drag and drop, and the fields order will be respected on [Entry Publish page](control-panel/create.md) (unless [Publish Layouts](control-panel/channels.md#publish-layouts) are used) as well as in [Fluid field custom field groups](fieldtypes/fluid.md#custom-field-groups).

docs/fieldtypes/fluid.md

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,24 @@ Fluid fields give the author control over the structure of their content, while
2323

2424
Select all fields that you want available in your fluid field on the publish page. All native fieldtypes except another fluid field are available.
2525

26+
### Custom field groups
27+
28+
Select custom field groups to make them available to fluid field on the publish page. All fields in group will be displayed together in the order set on field group page.
29+
2630
## Publish Page
2731

2832
### Add
2933

30-
A fluid field is initially displayed as a simple dropdown 'Add', populated with the field names assigned to the fluid field. When you choose a field from the dropdown, it adds it to the page, maintaing all of the field's settings, instructions and requirements.
34+
Each fluid field has list of buttons of available custom fields and custom field groups displayed below. Clicking on the button adds a field (or field group) to Fluid, maintaing all of the field's settings, instructions and requirements.
35+
36+
Also each Fluid row has '+' button, clicking which shows a dropdown populated with the field names assigned to the fluid field. When you choose a field from the dropdown, it adds it to the page
3137

32-
Fields can be used more than once and in any order. They can be re-ordered within the fluid field by dragging up or down.
38+
Fields (or field groups) can be used more than once and in any order. They can be re-ordered within the fluid field by dragging up or down.
3339

3440
The frontend will output the various field contents in the order specified in the entry.
3541

42+
NOTE: **Note:** Conditional fields are not supported inside Fluid
43+
3644
## Channel Form
3745

3846
A fluid field cannot be used in the channel form.
@@ -53,6 +61,24 @@ For example, if you have a Fluid field `fluid_content` with a text field `fluid_
5361

5462
The prefixed tag pair is a looping tag pair. You can have more than one `fluid_text` field for the entry, it's entirely at the entry author's discretion. The author also determines the order of the field output.
5563

64+
Displaying field groups from within Fluid field is sligtly different, as it requires additions `{fields}` tag pair.
65+
So given that `blog` is the short name of custom field group and `fluid_header` and `fluid_text` are fields in that group, the template might look like:
66+
67+
{fluid_content}
68+
69+
{fluid_content:blog}
70+
{fields}
71+
{fluid_content:fluid_header}
72+
<h3>{content}</h3>
73+
{/fluid_content:fluid_header}
74+
{fluid_content:fluid_text}
75+
<div>{content}</div>
76+
{/fluid_content:fluid_text}
77+
{/fields}
78+
{/fluid_content:blog}
79+
80+
{/fluid_content}
81+
5682
## Variables
5783

5884
TIP: **Tip:** When using any of these [tags with a parameter in a conditional](templates/conditionals.md#embedding-tags) you will have to wrap them in braces (`{}`), like so: `{if {fluid_content:first name="text_body"}}`
@@ -149,6 +175,56 @@ Alias of `:current_fieldtype`.
149175

150176
The total number of fields regardless of tag output criteria.
151177

178+
Additionally, the following variable are available when using custom field groups:
179+
180+
### `first_group`
181+
182+
{fluid_content:first_group}
183+
184+
True, if the current field group is the first one.
185+
186+
### `last_group`
187+
188+
{fluid_content:first_group}
189+
190+
True, if the current field group is the last one.
191+
192+
### `current_group_name`
193+
194+
{fluid_content:current_group_name}
195+
196+
The "human" name of the current field group being processed.
197+
198+
### `current_group_short_name`
199+
200+
{fluid_content:current_group_short_name}
201+
202+
The short name of the current field group being processed (as used in the templates).
203+
204+
### `next_group_name`
205+
206+
{fluid_content:next_group_name}
207+
208+
The "human" name of the next field group. This will be blank when on the last group.
209+
210+
### `next_group_short_name`
211+
212+
{fluid_content:next_group_short_name}
213+
214+
The short name of the next field group. This will be blank when on the last group.
215+
216+
### `prev_group_name`
217+
218+
{fluid_content:prev_group_name}
219+
220+
The "human" name of the previous field group. This will be blank when on the first group.
221+
222+
### `prev_group_short_name`
223+
224+
{fluid_content:prev_group_short_name}
225+
226+
The short name of the previous field group. This will be blank when on the first group.
227+
152228
## Displaying a Pair variable
153229

154230
Fields that use a variable pair to output content work like they would outside of a Fluid field, with the the `{content}` variable taking the place of the field shortname.

0 commit comments

Comments
 (0)