You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/guides/v2.3/ext-best-practices/tutorials/dynamic-row-system-config.md
+66-2Lines changed: 66 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -171,7 +171,71 @@ class TaxColumn extends Select
171
171
172
172
This block sets values for the drop-down option.
173
173
174
-
## Step 4: Clean cache
174
+
## Step 4: Set default values - OPTIONAL
175
+
176
+
It is possible to set defaults for a dynamic row configuration, this is done by adding additional XML to the defaults block in the `config.xml` file for the module.
177
+
178
+
Add a block to the `<default>` section of the `config.xml` file and do not include any values:
179
+
180
+
```xml
181
+
<system>
182
+
<general>
183
+
<ranges></ranges>
184
+
</general>
185
+
</system>
186
+
```
187
+
188
+
For each complete line of configuration, create an XML block with a repeating node that has a different value to all the others and contains XML tags for each sub-option and value.
189
+
For example, you can use `<item1>, <item2>`.
190
+
191
+
The sub-options are the columns defined in the `_prepareToRender()` method as described in [Step 2](#step-2-create-the-block-class-to-describe-custom-field-columns).
192
+
193
+
In the following excerpt, a single row for `item1` contains 4 sub-options:
194
+
195
+
```xml
196
+
<item1>
197
+
<from_qty>5</from_qty>
198
+
<to_qty>6</to_qty>
199
+
<price>10.00</price>
200
+
<tax>1</tax>
201
+
</item1>
202
+
```
203
+
204
+
Continue building the default block by adding 3 items to the `ranges` configuration option in the `config.xml` file:
205
+
206
+
```xml
207
+
<system>
208
+
<general>
209
+
<ranges>
210
+
<item1>
211
+
<from_qty>1</from_qty>
212
+
<to_qty>5</to_qty>
213
+
<price>10.00</price>
214
+
<tax>1</tax>
215
+
</item1>
216
+
<item2>
217
+
<from_qty>6</from_qty>
218
+
<to_qty>10</to_qty>
219
+
<price>20.00</price>
220
+
<tax>1</tax>
221
+
</item2>
222
+
<item3>
223
+
<from_qty>11</from_qty>
224
+
<to_qty>15</to_qty>
225
+
<price>30.00</price>
226
+
<tax>0</tax>
227
+
</item3>
228
+
</ranges>
229
+
</general>
230
+
</system>
231
+
```
232
+
233
+
To verify the default values for the configuration are correct, do the following :
234
+
235
+
- Ensure that this configuration option has no entry in the database.
236
+
- Continue with Step 5
237
+
238
+
## Step 5: Clean cache
175
239
176
240
Clean the Magento cache with the following command:
Copy file name to clipboardExpand all lines: src/guides/v2.3/frontend-dev-guide/layouts/xml-instructions.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,7 @@ We recommend always adding a `name` to blocks. Otherwise, it is given a random n
65
65
|`name`| Name that can be used to address the block to which this attribute is assigned. The name must be unique per generated page. If not specified, an automatic name will be assigned in the format <code>ANONYMOUS_<em>n</em></code> | 0-9, A-Z, a-z, underscore (_), period (.), dash (-). Should start with a letter. Case-sensitive. | no |
66
66
|`before`| Used to position the block before an element under the same parent. The element name or alias name is specified in the value. Use dash (-) to position the block before all other elements of its level of nesting. See [before and after attributes](#fedg_xml-instrux_before-after) for details. | Element name or dash (-) | no |
67
67
|`after`| Used to position the block after an element under the same parent. The element name or alias name is specified in the value. Use dash (-) to position the block after all other elements of its level of nesting. See [before and after attributes](#fedg_xml-instrux_before-after) for details. | Element name or dash (-) | no |
68
-
|`template`| A template that represents the functionality of the block to which this attribute is assigned. |`Vendor_Module::path/to/template.phtml` (Scope is already in the `templates` directory of the module) | no |
68
+
|`template`| A template that represents the functionality of the block to which this attribute is assigned. If the attribute is omitted, the block will not render any output. |`Vendor_Module::path/to/template.phtml` (Scope is already in the `templates` directory of the module) | no |
69
69
|`as`| An alias name that serves as identifier in the scope of the parent element. | 0-9, A-Z, a-z, underscore (_), period (.), dash (-). Case-sensitive. | no |
70
70
|`cacheable`| Defines whether a block element is cacheable. This can be used for development purposes and to make needed elements of the page dynamic. |`true` or `false`. Defaults to `true`. | no |
71
71
|`ifconfig`| Makes the block's visibility dependent on a system configuration field. | XPath to the system configuration field. E.g. `contact/contact/enabled`| no |
@@ -90,7 +90,7 @@ We recommend always adding a `name` to containers. Otherwise, it is given a rand
90
90
91
91
| Attribute | Description | Values | Required? |
92
92
|:------- |:------ |:------ |:------ |
93
-
|`name`| A name that can be used to address the container in which this attribute is assigned. The name must be unique per generated page. If not specified, it will be autogenerated. | A-Z, a-z, 0-9, underscore (_), period (.), dash (-). Should start with a letter. Case-sensitive. | No |
93
+
|`name`| A name that can be used to address the container in which this attribute is assigned. The name must be unique per generated page. If not specified, it will be auto-generated. | A-Z, a-z, 0-9, underscore (_), period (.), dash (-). Should start with a letter. Case-sensitive. | No |
94
94
|`label`| Describes the purpose of the container. | Any | No |
95
95
|`before`| Used to position the container before an element under the same parent. The element name or alias name is specified in the value. Use dash (-) to position the block before all other elements of its level of nesting. See [before and after attributes](#fedg_xml-instrux_before-after) for details. | Element name or dash (`-`) | No |
96
96
|`after`| Used to position the container after an element under the same parent. The element name or alias name is specified in the value. Use dash (-) to position the block after all other elements of its level of nesting. See [before and after attributes](#fedg_xml-instrux_before-after) for details. | Element name or dash (-). | No |
@@ -239,6 +239,9 @@ Example: add a block with a product [SKU](https://glossary.magento.com/sku) info
239
239
</block>
240
240
```
241
241
242
+
{:.bs-callout-info}
243
+
Declare the `template` attribute with the name of the module it belongs to: `template="<VendorName>_<ModuleName>::path-to-template.phtml"`. Following this approach avoids failures with template rendering and makes it easier for the developer to find and navigate to the template file.
244
+
242
245
## Set body attributes {#layout_body_attributes}
243
246
244
247
To set attributes for the HTML `body` tag use the `<attribute>` instruction.
0 commit comments