Extensible Buttons#

Colectica Portal allows you to create buttons that appear on an item’s page or on the basket page. When clicked, these buttons call an external web service.

Item Page Buttons

Buttons that appear on item detail pages and send the item’s identifier to a web service.

Basket Buttons

Buttons that appear on the basket page and send the basket’s contents to a web service.

Both kinds of button are configured in the same way, and are stored as part of the site information.

Button Settings#

Title

The text that appears on the button.

URL

The fully-specified URL to call when the button is clicked.

Request Method

Form POST will cause the browser to navigate to the specified URL, submitting a standard HTML form. Javascript POST will remain on the same page, and will submit a JSON request in the background.

Weight

The weight determines the order in which the button is displayed. Buttons with higher weights are displayed after lower weights.

Web Service Response for Javascript POST#

For both types of buttons, when the request method is Javascript POST, the web service should return JSON with both a message and a redirectUrl property. When a message is specified, that message is displayed to the user in a popup. When the message is null and a redirect URL is specified, the browser is redirected to that URL.

Response with a Message#
 {
     "message": "I received the following identification information: example.org:0ccc5a26-25b2-4a36-9f05-08ed1e2fec24:2",
     "redirectUrl": null
 }
Response with a Redirect URL#
 {
     "message": null,
     "redirectUrl": "http://www.example.org/"
 }

Note

The message property must be present in the response, with a null value, for the redirect to take place.

If the web service returns an HTTP error, the error status is displayed to the user.