With the help of the JetEngine plugins from crocoblock, you can easily display data from our software on your WordPress site.
Proceed as follows:
Preparation
- Request a non-expiring token via our REST interface (function: /nonexptoken). You can use Swagger on our interface or Postman.
- Purchase the JetEngine plugin from crocoblock and install it in your WordPress.
Creating a REST API endpoint
Proceed as described in How to set the connection between two websites using the REST API? on the JetEngine: How to Display Custom Content Type Items Using REST API page and use the following information:
- API Endpoint URL: https://api.beyond-sw.ch/kurse (or replace kurse with another entity of our interface.
- Items path: value
- Authorisation: Yes
- Authorisation type: Bearer Token
- Bearer token: Insert the token that you received during preparation in step 1.
Please note
For performance and memory reasons, it makes sense to restrict the amount of data to be retrieved via $select and/or $filter in the URL.
Example:
/Kurse?$select=kursId,titel&$filter=istAnmeldungMoeglich eq true
It may also be necessary to adjust the pagesize so that more than 100 entries are returned via the interface.
Example:
/Kurse?$select=kursId,titel&$filter=istAnmeldungMoeglich eq true&pagesize=500
Creating a query with Query Builder
Proceed according to the description How to Set Up REST API Query Type? on the JetEngine: Query Builder REST API Query Type page and use the following specifications:
- Query Type: REST API Query
- From Endpoint: Name of the previously created endpoint
- Query:
- Key: OData keyword (e.g. $select, $filter, $orderby)
- Value: OData expression
Please note
For performance and memory reasons, it makes sense to limit the amount of data to be queried via $select and/or $filter in the URL.
When creating a query with Query Builder, use the $select and/or $filter parameters for Query Key and Value.
It may also be necessary to adjust the pagesize so that more than 100 entries are returned via the interface.
Using query string parameters in a query
To filter a query with values from a query string, proceed as follows:
- For $filter-Key, select as Value Query Variable
- Under Advanced settings, compose the OData filter expression for Before and After
Use the Code Snippets plug-in, for example, to insert this code:
add_filter( ‘jet-engine/rest-api-listings/request/query-args’, function( $query_args ) {
foreach ( $query_args as $index => $value ) {
$query_args[ $index ] = wp_specialchars_decode( stripslashes($value), ENT_QUOTES );
}
return $query_args;
} );
Creating a Sub Query with Query Builder
Proceed according to the description Set Up a Sub Query to Retrieve the Array of Objects on the page JetEngine: How to Display Array Elements from REST API Endpoint Using Sub Query Addon and use the following specifications:
- Query Type: Sub Query
- Parent Object Property: Name of the NavigationProperty of the query of the enclosing listing (define $expand in the enclosing query)
- Create an entry in the item schema for each property that you want to use in the nested listing
Please note
For performance and memory reasons, it makes sense to restrict the amount of data to be queried via $select and/or $filterin the URL.
When creating a query with Query Builder, use the parameters $select and/or $filter for Query Key and Value.
It may also be necessary to adjust the pagesize so that more than 100 entries are returned via the interface.
Creating a dynamic link
If you want to create a link in a listing based on the Query Builder that uses a field from the Query Builder as part of the url, proceed as follows:
- Create an Options Page (under JetEngine -> Options Page) and use the following settings that differ from the default options:
- Page title: Freely selectable name, e.g. Login link
- Menu name: Freely selectable name, e.g. LoginLink
- Menu position: Freely selectable
- Insert a field:
- Label: Name of your choice, e.g. Url
- Navigate to the position you selected under 1.3.
- Enter the entire url in the field, which should appear before the dynamic part. E.G. https://test. ch/anmeldung/
- Switch to the Shortcode Generator (under JetEngine -> Shortcode Generator) and select the following options:
- Source: Post/Term/User/Object Data
- Title: select the field from the REST API (the REST API on which the query on which the listing is based) that you want to add dynamically in the url
- Copy the generated shortcode
- Switch to the Macros Generator and select the following options:
- Macros: Shortcode result
- Shortcode: Paste the shortcode copied under 4.3.
- Copy the generated macro
- In your listing, add a dynamic link and set the following options:
- Source: Options
- Option: Name that you selected under 1.1.
- Add Query Arguments: Yes
- Query Arguments: Enter the name of the desired query variable followed by an = sign followed by the macro copied under 5.3: e.g. _kursId=%shortcode_result|[jet_engine_data dynamic_field_post_object=‘kursId’]%
Comments
Please sign in to leave a comment.