Skip to content

Commit

Permalink
Allow browse start node id to be specified in the template (#82)
Browse files Browse the repository at this point in the history
(cherry picked from commit 669c833)
  • Loading branch information
pkamps authored and andrerom committed Dec 14, 2018
1 parent 4ad222e commit 0312f38
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -781,12 +781,9 @@ function customObjectAttributeHTTPAction( $http, $action, $contentObjectAttribut
'value' => $contentObjectAttribute->attribute( 'id' ) ),
'from_page' => $redirectionURI,
'cancel_page' => $redirectionURI,
'persistent_data' => array( 'HasObjectInput' => 0 ) );

if( $blockINI->hasVariable( $block->attribute( 'type' ), 'ManualBlockStartBrowseNode' ) )
{
$browseParameters['start_node'] = $blockINI->variable( $block->attribute( 'type' ), 'ManualBlockStartBrowseNode' );
}
'persistent_data' => array( 'HasObjectInput' => 0 ),
'start_node' => $this->getBrowseStartNodeId( $http, $blockINI, $contentObjectAttribute, $block, $params ),
);

eZContentBrowse::browse( $browseParameters, $module );
break;
Expand Down Expand Up @@ -1247,6 +1244,32 @@ function unserializeContentObjectAttribute( $package, $objectAttribute, $attribu
$xmlString = $rootNode ? $rootNode->ownerDocument->saveXML( $rootNode ) : '';
$objectAttribute->setAttribute( 'data_text', $xmlString );
}

/**
* @param eZHTTPTool $http
* @param eZINI $blockIni
* @param eZContentObjectAttribute $contentObjectAttribute
* @param eZPageBlock $block
* @param array $params
* @return int|null
*/
protected function getBrowseStartNodeId( $http, $blockIni, $contentObjectAttribute, $block, $params )
{
$return = null;

if( $http->hasVariable( 'start-browse-node-id' ) )
{
$startBrowseNodeIds = $http->variable( 'start-browse-node-id' );
$return = $startBrowseNodeIds[ $contentObjectAttribute->attribute( 'id' ) ][ $params[1] ][ $params[2] ];
}

if( !$return && $blockIni->hasVariable( $block->attribute( 'type' ), 'ManualBlockStartBrowseNode' ) )
{
$return = $blockIni->variable( $block->attribute( 'type' ), 'ManualBlockStartBrowseNode' );
}

return $return;
}
}

eZDataType::register( eZPageType::DATA_TYPE_STRING, "ezpagetype" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@
{/if}
{if and( not( $is_dynamic ), not( $is_custom ) )}
<div>
{if ezini( $block.type, 'ManualBlockStartBrowseNode', 'block.ini' )}
<input type="hidden" name="start-browse-node-id[{$attribute.id}][{$zone_id}][{$block_id}]" value="{ezini( $block.type, 'ManualBlockStartBrowseNode', 'block.ini' )}" />
{/if}
<input id="block-add-item-{$block_id}" class="button block-control" name="CustomActionButton[{$attribute.id}_new_item_browse-{$zone_id}-{$block_id}]" type="submit" value="{'Add item'|i18n( 'design/standard/block/edit' )}" />
</div>
{/if}
Expand Down

0 comments on commit 0312f38

Please sign in to comment.