Skip to content

Listings ​

Listings: titled collections of items (cards, directory entries) shown on a page. Reading is public; changing needs the signed-in portal session.

Quick start ​

ts
const result = await window.Portal.listings.fetchListing('LISTING_ID');
result.items.forEach((item) => console.log(item.title));

API reference ​

window.Portal.listings ​

Listings. Reading (fetchListings, fetchListing) is public; everything that creates, changes or deletes needs the signed-in portal session, so a public page uses only the reads.

createOrUpdateListing() ​

Creates a listing, or updates the one whose listing_id is given (signed in).

ts
const listing = await window.Portal.listings.createOrUpdateListing(listing);

Parameters

NameTypeRequiredDescription
listingPartial<PortalListing>YesA listing: a titled collection of items (cards, directory entries) shown on a page.

Returns

Resolves with a PortalListing: A listing: a titled collection of items (cards, directory entries) shown on a page.

createOrUpdateListingItem() ​

Creates or updates an item (signed in).

ts
const listingItem = await window.Portal.listings.createOrUpdateListingItem(listingId, item);

Parameters

NameTypeRequiredDescription
listingIdstringYesThe listing's id.
itemPartial<PortalListingItem>YesOne item of a listing.

Returns

Resolves with a PortalListingItem: One item of a listing.

deleteListing() ​

Deletes a listing (signed in).

ts
const ok = await window.Portal.listings.deleteListing(listingId);

Parameters

NameTypeRequiredDescription
listingIdstringYesThe listing's id.

Returns

Resolves with a boolean.

deleteListingItem() ​

Deletes an item (signed in).

ts
const ok = await window.Portal.listings.deleteListingItem(listingId, itemId);

Parameters

NameTypeRequiredDescription
listingIdstringYesThe listing's id.
itemIdstringYes—

Returns

Resolves with a boolean.

fetchListing() ​

One listing with its items.

ts
const result = await window.Portal.listings.fetchListing(listingId);

Parameters

NameTypeRequiredDescription
listingIdstringYesThe listing's id.

Returns

Resolves with an object with these fields:

NameTypeRequiredDescription
listingPortalListingYes—
itemsPortalListingItem[]Yes—

fetchListingItems() ​

The items of a listing.

ts
const listingItems = await window.Portal.listings.fetchListingItems(listingId);

Parameters

NameTypeRequiredDescription
listingIdstringYesThe listing's id.

Returns

Resolves with an array of PortalListingItem.

fetchListingOutput() ​

The rendered markup of a listing.

ts
const listingOutput = await window.Portal.listings.fetchListingOutput(listingId);

Parameters

NameTypeRequiredDescription
listingIdstringYesThe listing's id.

Returns

Resolves with a PortalListingOutput: A listing's rendered markup.

fetchListings() ​

All listings.

ts
const listings = await window.Portal.listings.fetchListings();

Returns

Resolves with an array of PortalListing.

saveListingOutput() ​

Stores the rendered markup of a listing (signed in).

ts
const ok = await window.Portal.listings.saveListingOutput(listingId, html, name);

Parameters

NameTypeRequiredDescription
listingIdstringYesThe listing's id.
htmlstringYes—
namestring | nullNoThe name.

Returns

Resolves with a boolean.

uploadListingImage() ​

Uploads an image for a listing item; app is the portal's application object (portal pages only).

ts
const result = await window.Portal.listings.uploadListingImage(file, app);

Parameters

NameTypeRequiredDescription
fileFileYesThe file.
appunknownYesUploads an image for a listing item; app is the portal's application object (portal pages only).

Returns

Resolves with an object with these fields:

NameTypeRequiredDescription
urlstringYesAn address.
generated_namestringYes—

Types ​

PortalListing ​

A listing: a titled collection of items (cards, directory entries) shown on a page.

NameTypeRequiredDescription
listing_idstringYesThe listing's id.
namestringYesThe listing's name.
internal_idstringYesThe owner's own id for the listing.
style_variantstringYesThe visual style.
details_page_enabledbooleanYesWhether each item has a details page.
configPortalListingConfigYesDisplay settings.
created_atstringNoISO creation time.
updated_atstringNoISO update time.

PortalListingConfig ​

A listing's display settings.

NameTypeRequiredDescription
style_variantstringYesThe visual style of the listing.
details_page_enabledbooleanYesWhether each item has its own details page.
[key: string]unknownNoFurther fields the server may add.

PortalListingItem ​

One item of a listing.

NameTypeRequiredDescription
listing_item_idstringYesThe item's id.
listing_idstringYesThe listing it belongs to.
titlestringYesThe item's title.
descriptionstringYesThe item's description.
imagesstring[]YesImage addresses.
details_titlestringNoHeading of the item's details page.
details_contentstringNoBody of the item's details page.
details_urlstringNoLink to the details page.
sort_ordernumberNoPosition in the listing (lowest first).
configRecord<string, unknown>NoItem display settings.
created_atstringNoISO creation time.
updated_atstringNoISO update time.

PortalListingOutput ​

A listing's rendered markup.

NameTypeRequiredDescription
listing_idstringYesThe listing.
typeactionnumberYesInternal output type code.
htmlstringYesThe HTML of the listing.
namestring | nullNoThe output's name, if any.