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.
Create Buttons¶
To create a button that appears on an item’s page, follow these steps.
Navigate to Admin and choose either Item Page Buttons or Basket Buttons.
Click Create a New Button.
Fill out the form.
- 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. JavascriptPost will remain on the same page, and will submit the 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.
Click Save.
Web Services for JavascriptPost¶
Item Page Buttons¶
The web service called by an item page button will receive a POST with application/json content in the request body.
{
"ItemIdentifier": "example.org:0ccc5a26-25b2-4a36-9f05-08ed1e2fec24:2"
}
Basket Buttons¶
The web service called by a basket button will receive a POST with application/json content in the request body.
{
"Citation": {
"Title": { "en-US": "My Basket of Variables" },
},
"ItemIdentifers": [
"example.org:0ccc5a26-25b2-4a36-9f05-08ed1e2fec24:2",
"example.org:f14cbeac-e266-4335-bf7f-e329eaa5843d:1",
"example.org:c074a069-4902-4634-8730-46b29455c9c8:1",
"example.org:3fc89da3-f93a-4037-a879-b2478d895209:1"
]
}
API Response¶
For both types of buttons, the web service should return JSON with one of two properties: message or redirectURL. When a message is specified, that message is displayed to the user. When a redirect URL is specified, the browser is redirected to that URL.
{
"message": "I received the following identification information: example.org:0ccc5a26-25b2-4a36-9f05-08ed1e2fec24:2",
}
{
"redirectUrl": "http://www.example.org/"
}