Display data in Wordpress with crocoblock JetEngine

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

  1. Request a non-expiring token via our REST interface (function: /nonexptoken). You can use Swagger on our interface or Postman.
  2. 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:

  1. API Endpoint URL: https://api.beyond-sw.ch/kurse (or replace kurse with another entity of our interface.
  2. Items path: value
  3. Authorisation: Yes
  4. Authorisation type: Bearer Token
  5. 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:

  1. Query Type: REST API Query
  2. From Endpoint: Name of the previously created endpoint
  3. Query:
    1. Key: OData keyword (e.g. $select, $filter, $orderby)
    2. 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:

  1. For $filter-Key, select as Value Query Variable
  2. 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:

  1. Query Type: Sub Query
  2. Parent Object Property: Name of the NavigationProperty of the query of the enclosing listing (define $expand in the enclosing query)
  3. 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:

  1. Create an Options Page (under JetEngine -> Options Page) and use the following settings that differ from the default options:
    1. Page title: Freely selectable name, e.g. Login link
    2. Menu name: Freely selectable name, e.g. LoginLink
    3. Menu position: Freely selectable
    4. Insert a field:
      1. Label: Name of your choice, e.g. Url
  2. Navigate to the position you selected under 1.3.
  3. Enter the entire url in the field, which should appear before the dynamic part. E.G. https://test. ch/anmeldung/
  4. Switch to the Shortcode Generator (under JetEngine -> Shortcode Generator) and select the following options:
    1. Source: Post/Term/User/Object Data
    2. 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
    3. Copy the generated shortcode
  5. Switch to the Macros Generator and select the following options:
    1. Macros: Shortcode result
    2. Shortcode: Paste the shortcode copied under 4.3.
    3. Copy the generated macro
  6. In your listing, add a dynamic link and set the following options:
    1. Source: Options
    2. Option: Name that you selected under 1.1.
    3. Add Query Arguments: Yes
    4. 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’]%
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.