Skip to content

Commit

Permalink
Merge pull request #172 from Anubarak/patch-4
Browse files Browse the repository at this point in the history
Fixed Twig syntax
  • Loading branch information
brandonkelly authored Aug 15, 2018
2 parents 3afdc57 + bb252ad commit c51cfd6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/dev/element-queries/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ You can also batch-set parameters like so:
{% set entries = craft.entries(
{
section: 'news',
orderBy: ['postDate' => SORT_DESC],
orderBy: {'postDate': SORT_DESC},
limit: 10
}
).all() %}
Expand All @@ -88,7 +88,7 @@ $entries = $query->all();
:::

::: warning
If you want to set the `orderBy` parameter like this, you must use the `['columnName' => SORT_ASC]` syntax rather than `'columnName asc'`.
If you want to set the `orderBy` parameter like this, you must use the `{'columnName': SORT_ASC}` syntax rather than `'columnName asc'`.
:::

### Param Value Syntax
Expand Down Expand Up @@ -125,8 +125,8 @@ For example, if you want to load entries with a custom `eventDate` field set wit
```php{7}
use craft\elements\Entry;
$start = new \DateTime('first day of next month');
$end = new \DateTime('last day of next month');
$start = new \DateTime('first day of next month')->format(\DateTime::ATOM);
$end = new \DateTime('last day of next month')->format(\DateTime::ATOM);
$entries = Entry::find()
->section('events')
->eventDate(['and', ">= {$start}", "<= {$end}"])
Expand Down

0 comments on commit c51cfd6

Please sign in to comment.