Skip to content

Commit

Permalink
IBX-1190: Updated readme to fit new template
Browse files Browse the repository at this point in the history
For more details see https://issues.ibexa.co/browse/IBX-1190 and #59

Co-authored-by: DominikaK <[email protected]>
  • Loading branch information
juskora and DominikaK authored Oct 20, 2021
1 parent 2c3b03c commit 16070cd
Showing 1 changed file with 6 additions and 58 deletions.
64 changes: 6 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,19 @@
# Ibexa Query Field Type

This Field Type will let a content manager map an executable Repository Query to a Field.
This package is part of [Ibexa DXP](https://ibexa.co).

Example use-cases:
- a `place.nearby_places` field that returns Place items less than X kilometers away
from the current content, based on its own `location` field
- a `gallery.images` field that returns Image items that are children of the current
gallery item's main location
To use this package, [install Ibexa DXP](https://doc.ibexa.co/en/latest/install/).

The idea is to move content and structure logic implemented in controllers and templates
to the repository itself.
This package contains the Query Field Type for [Ibexa DXP](https://ibexa.co).

## Installation
Add the package to the requirements:
```
composer require ezsystems/ezplatform-query-fieldtype:^1.0@dev
```

Enable the bundle:
```php
// config/bundles.php

return [
// ...
EzSystems\EzPlatformQueryFieldType\Symfony\EzSystemsEzPlatformQueryFieldTypeBundle::class => ['all' => true],
// ..
];
```

Add the bundle routes to `config/routing.yaml`:
```yml
ezplatform.query_fieldtype.routes:
resource: '@EzSystemsEzPlatformQueryFieldTypeBundle/Resources/config/routing/'
type: directory
```
## Usage
Add a Content query field to a content type.
In the Field Definition settings, select a Query Type from the list, as well as the content type that is returned by that field.
Parameters are used to build the query on runtime. They are either static, or mapped to properties from the content
the field value belongs to. The syntax YAML, with the key being the name of a query type parameter, and the value
either a scalar, or an [expression](https://symfony.com/doc/current/components/expression_language.html).
The following variables are available for use in expressions:
- `string returnedType`: the identifier of the content type that was previously selected
- `eZ\Publish\API\Values\Content\Content content`: the current content item
Also gives you access to fields values. Example with an `ezurl` field: `@=content.getFieldValue('url').link`
- `eZ\Publish\API\Values\Content\ContentInfo contentInfo`: the current content item's content info
- `eZ\Publish\API\Values\Content\Location mainLocation`: the current content item's main location

A simple example, for a LocationChildren query type that expects:
- `parent_location_id`: id of the location to fetch children for
- `content_types`: content type identifier or array of identifiers to filter on

````yaml
parent_location_id: "@=mainLocation.id"
content_types: "@=returnedType"
````

See the [`examples`](doc/examples/) directory for full examples.
This Field Type allows the content manager to map an executable Repository Query to a Field.

## COPYRIGHT

Copyright (C) 1999-2021 Ibexa AS (formerly eZ Systems AS). All rights reserved.

## LICENSE

This source code is available separately under the following licenses:

A - Ibexa Business Use License Agreement (Ibexa BUL),
Expand Down

0 comments on commit 16070cd

Please sign in to comment.