diff --git a/packages/ezflow_extension/ezextension/ezflow/datatypes/ezpage/ezpagetype.php b/packages/ezflow_extension/ezextension/ezflow/datatypes/ezpage/ezpagetype.php index 389f2c35..a8196da2 100644 --- a/packages/ezflow_extension/ezextension/ezflow/datatypes/ezpage/ezpagetype.php +++ b/packages/ezflow_extension/ezextension/ezflow/datatypes/ezpage/ezpagetype.php @@ -313,7 +313,14 @@ function fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute ) foreach ( $params as $param => $value ) { - $customAttributes[$param] = $value; + if (is_array($value)) + { + $customAttributes[$param] = implode(',', $value); + } + else + { + $customAttributes[$param] = $value; + } } $block->setAttribute( 'custom_attributes', $customAttributes ); diff --git a/packages/ezflow_extension/ezextension/ezflow/design/standard/templates/block/edit/edit.tpl b/packages/ezflow_extension/ezextension/ezflow/design/standard/templates/block/edit/edit.tpl index 7c53d402..6797b2dc 100644 --- a/packages/ezflow_extension/ezextension/ezflow/design/standard/templates/block/edit/edit.tpl +++ b/packages/ezflow_extension/ezextension/ezflow/design/standard/templates/block/edit/edit.tpl @@ -86,6 +86,11 @@ $custom_attribute_types = array() $custom_attribute_names = array() $custom_attribute_selections = array() + $custom_attribute_value = '' + $custom_attribute_values = array() + $custom_attribute_default = '' + $custom_attribute_multiselect_setting = false() + $custom_attribute_multiselect_value = false() $loop_count = 0} {if ezini_hasvariable( $block.type, 'CustomAttributes', 'block.ini' )} {set $custom_attributes = ezini( $block.type, 'CustomAttributes', 'block.ini' )} @@ -129,12 +134,66 @@ {/case} {case match = 'select'} - {set $custom_attribute_selections = ezini( $block.type, concat( 'CustomAttributeSelection_', $custom_attrib ), 'block.ini' )} - + {set $custom_attribute_selections = ezini( $block.type, concat( 'CustomAttributeSelection_', $custom_attrib ),'block.ini' )} + + {* Check if there is a default value for the select *} + {if ezini_hasvariable( $block.type, concat( 'CustomAttributeSelectionDefault_', $custom_attrib ), 'block.ini' )} + {set $custom_attribute_default = ezini( $block.type, concat( 'CustomAttributeSelectionDefault_', $custom_attrib ), 'block.ini' )} + {else} + {set $custom_attribute_default = ''} + {/if} + + {* Check if this is a new block *} + {if is_set( $block.custom_attributes[$custom_attrib] )} + {set $custom_attribute_value = $block.custom_attributes[$custom_attrib]} + {else} + {set $custom_attribute_value = $custom_attribute_default} + {/if} + + {* Test for multiselect option *} + {set $custom_attribute_multiselect_setting = ezini_hasvariable( $block.type, concat( 'CustomAttributeSelectionMultiple_', $custom_attrib ), 'block.ini' )} + {* If multiselect select option is set, use the value *} + {if $custom_attribute_multiselect_setting} + {* If multiselect is enabled *} + {set $custom_attribute_multiselect_value = ezini( $block.type, concat( 'CustomAttributeSelectionMultiple_', $custom_attrib ), 'block.ini' )|eq( 'enabled' )} + {else} + {* Default value is false - single select *} + {set $custom_attribute_multiselect_value = false()} + {/if} + + {* Set custom_attribute_values based on the multiselect setting value *} + {if $custom_attribute_multiselect_value} + {set $custom_attribute_values = $custom_attribute_value|explode(',')} + {else} + {set $custom_attribute_values = array( $custom_attribute_value )} + {/if} + + + {def $i_selected = ''} + {/case} {case} diff --git a/packages/ezflow_extension/ezextension/ezflow/settings/block.ini b/packages/ezflow_extension/ezextension/ezflow/settings/block.ini index 794da2e3..8720c437 100644 --- a/packages/ezflow_extension/ezextension/ezflow/settings/block.ini +++ b/packages/ezflow_extension/ezextension/ezflow/settings/block.ini @@ -72,9 +72,27 @@ RootSubtree=1 # text / checkbox / select / string (default) # CustomAttributeTypes[node_id]=string # CustomAttributeTypes[color]=select +# Select attribute configuration +# CustomAttributeSelection_name[value]=Label +# name must correspond to a CustomAttributeTypes[name]=select setting +# value is the value which will be stored. It MUST NOT contain commas. +# Label is the label that will be displayed in the select input. It may be any string. +# CustomAttributeSelectionDefault_name=value +# This sets the default value of the select input. value must match a CustomAttributeSelection_name[value] setting +# Multiple values may be included, separated by commas +# If this value is omitted, the default is assumed to be an empty string +# CustomAttributeSelectionEmpty_name=enabled +# Indicates whether the selection can be empty. When enabled, an empty value with the label '--' will be added to the select +# CustomAttributeSelectionMultiple_name=enabled +# Multiple selections may be enabled by setting CustomAttributeSelectionMultiple_name to enabled # CustomAttributeSelection_color[] # CustomAttributeSelection_color[blue]=Blue # CustomAttributeSelection_color[green]=Green +# CustomAttributeSelection_color[red]=Red +# Set the default +# CustomAttributeSelectionDefault_color=green,red +# Allow multiple items to be selected +# CustomAttributeSelectionMultiple_color=enabled # UseBrowseMode[node_id]=true # Optional: set the browse mode start node for a custom attribute # CustomAttributeStartBrowseNode[node_id]=