description |
---|
Customize the configuration of the content browser. |
Browsing the content structure and selecting content from the Repository uses the module Universal Discovery Widget (UDW). UDW has an interactive interface which allows you to create, move or copy content items.
UDW requires that you provide configuration by using the ibexa_udw_config
Twig helper. This configuration must be spread to the props of the component itself.
<button data-udw-config="{{ ibexa_udw_config('single') }}">
Open My UDW
</button>
single
configuration is one of the default configuration provided. You can also do your own configuration.
With plain JS:
const container = document.querySelector('#react-udw');
const config = /* fetch the config somewhere */;
//const config = JSON.parse(document.querySelector('.btn-udw-trigger).dataset.udwConfig);
ReactDOM.render(React.createElement(ibexa.modules.UniversalDiscovery, {
onConfirm: {Function},
onCancel: {Function},
...config
}), container);
With JSX:
const props = {
onConfirm: {Function},
onCancel: {Function}
};
const config = /* fetch the config somewhere */;
<UniversalDiscoveryModule {...props} {...config} />
You can configure UDW under the ibexa.system.<scope>.universal_discovery_widget_module.configuration
configuration key.
There you can set the following properties:
YML React props |
Values | Required | Definition |
---|---|---|---|
multiplemultiple |
true false |
no | The possibility to choose multiple Locations. |
multiple_items_limitmultipleItemsLimit |
number | no | Maximum number of items with configuration multiple: true . |
root_location_idrootLocationId |
number | no | UDW will display Locations only below this Content Tree element. |
starting_location_idstartingLocationId |
number | no | This Location will be displayed as a starting Location in UDW. |
containers_onlycontainersOnly |
true false |
no | When set to true only containers can be selected. |
allowed_content_typesallowedContentTypes |
null [] [ contentTypeIdentifier ] |
yes | List of allowed content types:null – all content types are allowed,[] – empty table, no content types are allowed. |
active_sort_clauseactiveSortClause |
DatePublished ContentName |
no | Sort Clause by which children in the Content Tree will be sorted. |
active_sort_orderactiveSortOrder |
ascending descending |
no | Sorting order of the children in the Content Tree. |
active_tabactiveTab |
browse search bookmarks |
no | Starting tab in the UDW. |
active_viewactiveView |
finder grid tree |
no | Starting view in the UDW. |
allow_redirectsallowRedirects |
true false |
yes | Allows to redirect content from the UDW tab to another page, for example, to Content Edit page. |
selected_locationsselectedLocations |
[] [locationId] |
no | Location that will be selected automatically. |
allow_confirmationallowConfirmation |
true false |
yes | Shows confirmations buttons in the UDW. If set to false, it will not be possible to confirm selection. |
YML React props |
Values | Required | Definition |
---|---|---|---|
allowed_languagesallowedLanguages |
null [] [languageCode] |
yes | Languages available in Content on the Fly:null - all,[] - none. |
allowed_locationsallowedLocations |
null [] [locationId] |
yes | Location under which creating content is allowed:null - everywhere,[] - nowhere. |
preselected_languagepreselectedLanguage |
null languageCode |
yes | First language on the Content on the Fly language list: null - language order defined in the system. |
preselected_content_typepreselectedContentType |
null contentTypeIdentifier |
yes | Content selected in Content on the Fly. |
hiddenhidden |
true false |
yes | Content on the Fly visibility. |
auto_confirm_after_publishautoConfirmAfterPublish |
true false |
yes | If set to true UDW will be automatically closed after publishing the content. |
General configuration for tabs, for example, browse, search, bookmarks.
YML React props |
Values | Required | Definition |
---|---|---|---|
items_per_pageitemsPerPage |
number | yes | Number of items shown on one page. |
prioritypriority |
number | yes | Priority of items shown in the tab list. Item with a highest value is displayed as first. |
hiddenhidden |
true false |
yes | Hides or reveals specific tabs. |
React props | Values | Required | Definition |
---|---|---|---|
onConfirm |
function | yes | A callback to be invoked when a user clicks the confirm button in a Universal Discovery Widget. |
onCancel |
function | yes | A callback to be invoked when a user clicks the cancel button in a Universal Discovery Widget. |
title |
string | yes | The title of Universal Discovery Widget. |
UDW configuration is SiteAccess-aware. For each defined SiteAccess, you need to be able to use the same configuration tree to define SiteAccess-specific config. These settings need to be mapped to SiteAccess-aware internal parameters that you can retrieve with the ConfigResolver.
UDW configuration can change dynamically depending on occurring events. You can use it, for example, to define which content should be exposed to a user after logging in.
By default, only one element from configuration file is applied to Universal Discovery Widget.
You can modify it dynamically by passing context to generate configuration based on a specific event.
This context event is caught by event listener ConfigResolveEvent::NAME
before the original configuration is used.
Depending on what additional parameters are provided, original or event-specific configuration is applied.
In the example below my_custom_udw
is used as a base configuration element for the following steps:
ibexa:
system:
<siteaccess|siteaccess_group>:
universal_discovery_widget_module:
configuration:
my_custom_udw:
multiple: false
In the ibexa_udw_config
Twig helper, define a specific part of YAML configuration that will be used to render the Content Browser.
You can find Twig helper in your button template.
In the example below, a key is pointing to my_custom_udw
configuration and has additional parameter johndoe
.
<button class="btn btn-primary open-my-custom-udw" data-udw-config="{{
ibexa_udw_config('my_custom_udw', {
'some_contextual_parameter': 'johndoe'
}
) }}">
Open My UDW
</button>
If an event listener catches additional parameters passed with context, it will use a configuration specified for it in the event subscriber.
In the example below, the johndoe
parameter enables the user to choose multiple items from a Browser window by changing multiple: false
from my_custom_udw
configuration to multiple: true
.
class JohnDoeCanSelectMore implements EventSubscriberInterface
{
private const CONFIGURATION_NAME = 'my_custom_udw';
/**
* Returns an array of event names this subscriber wants to listen to.
*
* @return array The event names to listen to
*/
public static function getSubscribedEvents()
{
return [
ConfigResolveEvent::NAME => 'onUdwConfigResolve',
];
}
/**
* @param \Ibexa\AdminUi\UniversalDiscovery\Event $event
*/
public function onUdwConfigResolve(ConfigResolveEvent $event)
{
if ($event->getConfigName() !== self::CONFIGURATION_NAME) {
return;
}
$config = $event->getConfig();
$context = $event->getContext();
if (isset($context['some_contextual_parameter'])) {
if ($context['some_contextual_parameter'] === 'johndoe') {
$config['multiple'] = true;
}
}
$event->setConfig($config);
}
}
For more information, see [Symfony Doctrine Event Listeners and Subscribers tutorial]([[= symfony_doc =]]/event_dispatcher.html#creating-an-event-subscriber).