Skip to content

Commit

Permalink
merge with main
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzmg committed May 14, 2022
2 parents 36015a4 + dfb14be commit 009d05e
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 6 deletions.
6 changes: 4 additions & 2 deletions docs/dev/reference/dca/fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $GLOBALS['TL_DCA']['tl_example']['fields']['myfield'] = [
| filter | true/false (`bool`) | If true the field will be included in the filter menu (see "sorting records" -> "panelLayout"). |
| flag | Sorting mode (`integer`) | **1** Sort by initial letter ascending <br>**2** Sort by initial letter descending <br>**3** Sort by initial X letters ascending (see length) <br>**4** Sort by initial X letters descending (see length) <br>**5** Sort by day ascending <br>**6** Sort by day descending <br>**7** Sort by month ascending <br>**8** Sort by month descending <br>**9** Sort by year ascending <br>**10** Sort by year descending <br>**11** Sort ascending <br>**12** Sort descending<br><br><i>Note:</i> flags 5 through 10 will also enable formatting of timestamps in the back end when used as a label somewhere. |
| length | Sorting length (`integer`) | Allows to specify the number of characters that are used to build sorting groups (flag **3** and **4**). |
| inputType | Field type (`string`) | **checkbox** Checkbox <br>**checkboxWizard** Checkbox Wizard <br>**chmod** CHMOD table <br>**fileTree** File tree <br>**imageSize** Two text fields with drop-down menu (creates an [Image Size Array](/framework/image-processing/image-sizes/#size-array))<br>**inputUnit** Text field with small unit drop-down menu <br>**keyValueWizard** Key » Value wizard <br>**listWizard** List wizard <br>**metaWizard** Used for setting meta information in the file manager <br>**moduleWizard** Module wizard <br>**optionWizard** Option wizard <br>**pageTree** Page tree <br>**password** Password field <br>[**picker**][PickerWidget] General purpose picker <br>**radio** Radio button <br>**radioTable** Table with images and radio buttons <br>**sectionWizard** Used for defining sections in the page layout <br>**select** Drop-down menu <br>**serpPreview** Search Engine Result Preview (SERP) widget<br>**tableWizard** Table wizard <br>**text** Text field <br>**textStore** Text field that will not display its current value <br>**textarea** Textarea <br>**timePeriod** Text field with drop-down menu <br>**trbl** Four text fields with a small unit drop-down menu |
| inputType | Field type (`string`) | `checkbox` Checkbox <br>`checkboxWizard` Checkbox Wizard <br>`chmod` CHMOD table <br>`fileTree` File tree <br>`imageSize` Two text fields with drop-down menu (creates an [Image Size Array](/framework/image-processing/image-sizes/#size-array)) <br>`inputUnit` Text field with small unit drop-down menu <br>`keyValueWizard` Key » Value wizard <br>[`listWizard`][ListWizardWidget] List wizard <br>`metaWizard` Used for setting meta information in the file manager <br>`moduleWizard` Module wizard <br>`optionWizard` Option wizard <br>`pageTree` Page tree <br>`password` Password field <br>[`picker`][PickerWidget] General purpose picker <br>`radio` Radio button <br>`radioTable` Table with images and radio buttons <br>`sectionWizard` Used for defining sections in the page layout <br>[`select`][SelectWidget] Drop-down menu <br>`serpPreview` Search Engine Result Preview (SERP) widget <br>`tableWizard` Table wizard <br>`text` Text field <br>`textStore` Text field that will not display its current value <br>`textarea` Textarea <br>`timePeriod` Text field with drop-down menu <br>`trbl` Four text fields with a small unit drop-down menu |
| options | Options (`array`) | Options of a drop-down menu or radio button menu.<br />Specify as `['opt1', 'opt2', 'opt3']` or `['value1' => 'label1', 'value2' => 'label2']`.<br />Special case **ambiguous numerical value/index**: `[0 => 'label1', 1 => 'label2']` or `['0' => 'label1', '1' => 'label2']`: If option values are integers and starting with 0, the label will also be used as value. Use the eval option `isAssociative` to prevent this. |
| [options_callback](../callbacks/#fields-field-options) | Callback function (`array`) | Callback function that returns an array of options. Please specify as `['Class', 'Method']`. |
| foreignKey | table.field (`string`) | Get options from a database table. Returns ID as key and the field you specify as value. The field can be a complete SQL expression, e.g.: `tl_member.CONCAT(firstname,' ',lastname)` |
Expand Down Expand Up @@ -137,7 +137,7 @@ Each field can be validated against a regular expression.
| csv | Delimiter (`string`) | The choice of this field will not be stored as serialized string but rather as given delimiter-separated list. Example: `'eval' => ['csv'=>',']` |
| customRgxp | Regular expression (`string`) | {{< version "4.11" >}} Custom regular expression to be used when using `'rgxp' => 'custom'` |
| datepicker | true/false (`bool`) | If true the current field will have a [MooTools-DatePicker](https://github.com/arian/mootools-datepicker). |
| dcaPicker | true/false (`bool`) | If true the dca-picker will be shown. Enables pick up different data sets from the system. |
| dcaPicker | true/false (`bool`) | If true the general purpose picker will be shown. Allows to pick different records from the system and return them as an insert tag. |
| decodeEntities | true/false (`bool`) | If true HTML entities will be decoded. Note that HTML entities are always decoded if allowHtml is true. |
| disabled | true/false (`bool`) | Disables the field (not supported by all field types). |
| doNotCopy | true/false (`bool`) | If true the current field will not be duplicated if the record is duplicated. |
Expand Down Expand Up @@ -314,4 +314,6 @@ the Doctrine Database Abstraction Layer.
[2]: http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/schema-representation.html#column
[3]: ../../../framework/hooks/
[TranslationDomain]: /framework/translations/#domains
[ListWizardWidget]: /reference/widgets/list-wizard/
[PickerWidget]: /reference/widgets/picker/
[SelectWidget]: /reference/widgets/select/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/dev/reference/widgets/images/select.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
155 changes: 153 additions & 2 deletions docs/dev/reference/widgets/select.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,157 @@
---
title: "Select Menu"
description: Drop-down menu (not yet documented)
description: Renders a drop-down menu
---

{{< widget-notice >}}
This widget renders a drop-down menu.

A simple select menu with hard-coded options whether to show the current page in the HTML Sitemap:

![Select menu with hard-coded options](../images/select.png?classes=shadow)

A select menu enhanced with Chosen.js to allow the editor to limit the available options with a simple search box:

![Select menu enhanced with Chosen.js](../images/select-chosen.png?classes=shadow)

A grouped select menu enhanced with Chosen.js:

![Grouped select menu enhanced with Chosen.js](../images/select-grouped-chosen.png?classes=shadow)

## Options

This table only shows the options relevant to the core functionality of this widget. See the DCA reference for a [full field reference](../../dca/fields).

| Key | Value | Description
| ----- | ----- | --------------- |
| `inputType` | `select` | |
| `options` | `array` | An options array (use in combination with `eval.multiple`) |
| `options_callback` | `function\|callable` | A callback function that returns the options callback or an array (use in combination with `eval.multiple`). You may define an anonymous function, but you should consider [registering them via annotations](../../../framework/dca/#registering-callbacks). |
| `reference` | `array` | Reference an array that will be used to translate the options. Contao will automatically match the options and reference array by key. |
| `foreignKey` | `string` | Reference another table to generate options from. |
| `eval.multiple` | true/false (default) `bool` | Set this to true if you want to provide multiple options via `options` or `options_callback` |
| `eval.includeBlankOption` | true/false (default) `bool` | Includes a blank option (useful in conjunction with `mandatory` fields) |
| `eval.blankOptionLabel` | `string` (default `-`) | The label of the blank option |
| `eval.chosen` | true/false (default) `bool` | Enhance the select menu with Chosen.js |

The `options` array – either set directly or returned by an options callback – can have different structures depending on what you are going for:

1. `[ 'label1' , 'label2' ]` where the values of the select options will be the regular array index.
2. `[ 'value' => 'label' ]` where `value` will be the value of the select option, and `label` the label.
3. `[ 'foo' => ['a', 'b'], 'bar' => ['c', 'd'] ]` which will render grouped select options `foo` and `bar`.

## Column Definition

Depending on the widget configuration, the widget persists different values to the database. You have to take care of the correct SQL column definition yourself. A **single** select will save the selected value as string. If you allow to select **multiple** options, they are stored as serialized array. Since you do not know the length in advance, a blob column is prefered.

## Examples

{{< tabs >}}

{{% tab name="Simple select" %}}

If you simply want to select an option from a fixed set.

```php
// ...
'isVisible' => [
'label' => ['Visibility', 'Whether this element is visible on the page'],

'inputType' => 'select',
'options' => ['always', 'never', 'auto'],

'sql' => [
'type' => 'string',
'length' => 8, // Must be large enough to store all possible values
'default' => 'auto',
],
],
// ...
```

{{% /tab %}}

{{% tab name="Grouped select" %}}

If you simply want to select one option from a fixed set of grouped options.

```php
// ...
'mySelect' => [
'label' => ['Select', 'Help text'],
'inputType' => 'select',
'options' => [
'news' => [
'news_reader',
'news_list',
],
'events' => [
'event_reader',
'event_list',
],
],
'sql' => [
'type' => 'string',
'length' => 16, // Must be large enough to store all possible options
'default' => '',
],
],
// ...
```

{{% /tab %}}

{{% tab name="Dynamic options with search box" %}}

You can also dynamically generate the options array to filter them as you wish. See the [options callback](../../dca/callbacks#fields-field-options) for further examples.

```php
// ...
'mySelect' => [
'label' => ['Select', 'Help text'], // Or a reference to the global language array
'inputType' => 'select',
'options_callback' => [
'Vendor\Class', 'getMySelectOptions' // Defines a method that returns the options array. Class can be a service.
],
'eval' => [
'chosen' => true, // Adds a search box to filter the options
],
'sql' => [
'type' => 'string',
'length' => 16, // Must be large enough to store all possible options
'default' => '',
],
],
// ...
```

{{% /tab %}}

{{% tab name="Options from a table" %}}

You can generate an options array from another table with the `foreignKey` property.

```php
// ...
'myUsers' => [
'label' => ['My Users', 'Help text'], // Or a reference to the global language array
'inputType' => 'select',
'foreignKey' => 'tl_user.name', // Will use `name` as label, and the user `id` as value
'eval' => [
'chosen' => true, // Adds a search box to filter the options
],
'sql' => [
'type' => 'string',
'notnull' => false,
'default' => '',
],
],
// ...
```

{{% /tab %}}

{{< /tabs >}}

## Usage in Contao

Basically everywhere, e.g. `tl_page` or `tl_module`
7 changes: 6 additions & 1 deletion docs/manual/cli/crawl.de.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ Die Optionen sind viel wichtiger:
| `--max-requests` | Standardmäßig ist kein Limit konfiguriert. Aber wenn du nur eine bestimmte Anzahl von Anfragen insgesamt ausführen möchtest, kannst du dies mit dieser Option erreichen. Zur weiteren, späteren Ausführung berücksichtige das Argument `job`. |
| `--max-depth` | Dies ist die Tiefe der Hierarchie, die der Crawler durchsuchen wird. Die Wurzelseite ist im Grunde Ebene 1 und alle dort gefundenen Links gehören zur Ebene 2. Alle Links, die auf Ebene 2 gefunden werden, gehören zur Ebene 3 und so weiter. Standardmäßig ist keine maximale Tiefe konfiguriert. Je höher die Zahl, desto tiefer wird der Crawler suchen, aber es wird auch länger dauern. |
| `--enable-debug-csv` | Standardmäßig werden die Ergebnisse in die Standardausgabe geschrieben. Du kannst hierüber alles in eine CSV-Datei schreiben lassen. |
| `--debug-csv-path` | Mit dieser Option kannst du den Standard-CSV-Dateipfad überschreiben, wenn du `--enable-debug-csv` verwendet hast. |
| `--debug-csv-path` | Mit dieser Option kannst du den Standard-CSV-Dateipfad überschreiben, wenn du `--enable-debug-csv` verwendet hast. |

**Hinweise**

* Stelle sicher, dass die korrekte Domain im Startpunkt der Webseite eingetragen ist. Alternativ kann auch die Standard-Domain über den `router.request_context.host` Parameter festgelegt werden.
* Geschützte Seiten können aktuell nur über das Backend indexiert werden.
7 changes: 6 additions & 1 deletion docs/manual/cli/crawl.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,9 @@ The options are far more important so let's get to them right away:
| `--max-requests` | By default, there is no limit configured but if you want to only execute a certain number of requests in total, you can do that with this option. If you want to pick up the job later, see the `job` argument. |
| `--max-depth` | This is the tree depth, the crawler is going to search. The root page is basically level 1 and all the links found there will be level 2. All the links found on level 2 will be level 3 and so on. By default, there is no max-depth configured. The higher the number, the deeper the crawler will search but it will also take longer. |
| `--enable-debug-csv` | By default the subscriber results are written to the standard output. You can ask the command to write everything to a CSV file by passing this option. |
| `--debug-csv-path` | This option allows you to override the default CSV file path, if you used `--enable-debug-csv`. |
| `--debug-csv-path` | This option allows you to override the default CSV file path, if you used `--enable-debug-csv`. |

**Notes**

* Make sure you have defined the correct domain in either your website root or a default domain via the `router.request_context.host` parameter.
* Protected pages can currently only be indexed via the backend.

0 comments on commit 009d05e

Please sign in to comment.