Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' )}
Expand Down Expand Up @@ -129,12 +134,66 @@
<input id="block-custom_attribute-{$block_id}-{$loop_count}" class="textfield block-control" type="text" name="ContentObjectAttribute_ezpage_block_custom_attribute_{$attribute.id}[{$zone_id}][{$block_id}][{$custom_attrib}]" value="{$block.custom_attributes[$custom_attrib]|wash()}" />
{/case}
{case match = 'select'}
{set $custom_attribute_selections = ezini( $block.type, concat( 'CustomAttributeSelection_', $custom_attrib ), 'block.ini' )}
<select id="block-custom_attribute-{$block_id}-{$loop_count}" class="block-control" name="ContentObjectAttribute_ezpage_block_custom_attribute_{$attribute.id}[{$zone_id}][{$block_id}][{$custom_attrib}]">
{foreach $custom_attribute_selections as $selection_value => $selection_name}
<option value="{$selection_value|wash()}"{if eq( $block.custom_attributes[$custom_attrib], $selection_value )} selected="selected"{/if} />{$selection_name|wash()}</option>
{/foreach}
</select>
{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 = ''}
<select id="block-custom_attribute-{$block_id}-{$loop_count}" class="block-control" name="ContentObjectAttribute_ezpage_block_custom_attribute_{$attribute.id}[{$zone_id}][{$block_id}][{$custom_attrib}]{if $custom_attribute_multiselect_value}[]" multiple="multiple" size="{min($custom_attribute_selections|count(), 6)}{else}" size="1{/if}">

{* If an allow empty option has been set *}
{if ezini_hasvariable( $block.type, concat( 'CustomAttributeSelectionEmpty_', $custom_attrib ), 'block.ini' )}
{* Test allow empty option, this ensures the value is sent to the server and set *}
{if ezini( $block.type, concat( 'CustomAttributeSelectionMultiple_', $custom_attrib ), 'block.ini' )|eq( 'enabled' )}
<option value="" {if $custom_attribute_value|eq('')}selected="selected"{/if} title="Empty/No selection">--</option>
{/if}
{/if}

{foreach $custom_attribute_selections as $selection_value => $selection_name}

{* mark option as selected *}
{set $i_selected = ''}
{foreach $custom_attribute_values as $value}
{if eq( $value|trim(), $selection_value|trim() )}
{set $i_selected = 'selected="selected"'}
{break}
{/if}
{/foreach}

<option value="{$selection_value|trim()|wash()}" {$i_selected}>{$selection_name|wash()}</option>
{/foreach}
</select>
{/case}
{case}
<input id="block-custom_attribute-{$block_id}-{$loop_count}" class="textfield block-control" type="text" name="ContentObjectAttribute_ezpage_block_custom_attribute_{$attribute.id}[{$zone_id}][{$block_id}][{$custom_attrib}]" value="{$block.custom_attributes[$custom_attrib]|wash()}" />
Expand Down
18 changes: 18 additions & 0 deletions packages/ezflow_extension/ezextension/ezflow/settings/block.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]=<node_id>
Expand Down