-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from AlexaCRM/updateTwig
to discuss twig
- Loading branch information
Showing
8 changed files
with
209 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"label": "Using Twig", | ||
"position": 4, | ||
"link": { | ||
"type": "generated-index" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
sidebar_position: 2 | ||
title: Filters and function | ||
slug: /twig/filters_and_function | ||
tags: | ||
- Twig | ||
- DataPress | ||
keywords: [DataPress twig] | ||
--- | ||
|
||
## Filters | ||
|
||
DataPress (Dataverse Integration) provides several Dataverse-specific and general purpose Twig filters. | ||
|
||
- `formatted_value( attributeName )` -- returns the formatted value of the filtered entity record as reported by Dataverse. Returns the entity record attribute value if no formatted value available. | ||
E.g. `record|formatted_value( "preferredappointmenttimecode" )` | ||
- `to_entity_reference` -- converts an Entity object, or an EntityReference-like object to a strongly typed EntityReference object. For an EntityReference-like object, the filter expects `LogicalName` (required), `Id` and `Name` keys. | ||
E.g. `record|to_entity_reference` or `{ "LogicalName": "contact", "Id": "00000000-0000-0000-0000-000000000000" }` | ||
- `add_query( queryName, queryValue )` -- adds a GET query argument to the filtered URL, honors the already existing query string which allows piping. | ||
- `wpautop` -- see [WordPress wpautop() docs](https://developer.wordpress.org/reference/functions/wpautop/). | ||
|
||
## Functions | ||
|
||
```twig | ||
- image_url( | ||
record, | ||
column, | ||
isThumb, | ||
{ | ||
"Content-Disposition": "inline", | ||
"Content-Type": "text/html; charset=utf-8", | ||
"Cache-Control": "max-age=604800" | ||
} | ||
) | ||
``` | ||
-- returns URL to the image stored in the specified Dataverse image column. | ||
|
||
```twig | ||
- file_url( | ||
record, | ||
column, | ||
{ | ||
"Content-Disposition": "inline", | ||
"Content-Type": "text/html; charset=utf-8", | ||
"Cache-Control": "max-age=604800" | ||
} | ||
) | ||
``` | ||
-- returns download URL for the file stored in the specified Dataverse file column. | ||
|
||
- `last_error()` - returns last error generated by the Twig provider. | ||
|
||
- `entity_url( record, postId = null )` -- returns URL to the website page with the given entity record bound to it. Uses [Table Binding](/datapress/binding/table-binding.md) feature. If more than one WordPress post is bound to the table, you can pass post ID to link to a different page instead. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.