Blog

BranchCMS Upgrades

Eric Tompkins
Mar 27, 2019

API Updates

We pushed out an update today that renames a number of the internal app API methods to some more intuitive names. Essentially we removed "Filter" from the API method names and made the API method names plural.

Below is a list of the updated API methods. The old method names will continue to work but we do not recommend using them anymore as they are deprecated.

App Old Method Name New Method Name
All apps supporting categories categoryFilter categories
All apps supporting tags tagFilter tags
App itemFilter items
Blog postFilter posts
Calendar eventFilter events
Classifieds listingFilter listings
Directory profileFilter profiles
Documents documentFilter documents
Employment jobFilter jobs
Gallery itemFilter items
Members profileFilter profiles
Real Estate agentFilter agents
Real Estate propertyFilter properties
Rental propertyFilter properties
Rental propertyUnitFilter propertyUnits
Store manufacturerFilter manufacturers
Store productFilter products
Trails badgeFilter badges
Trails trailFilter trails
Trails trailNamesFilter trailNames

 

Below is an example

{# Wrong: Don't use itemFilter anymore #}
{{ _api.app.itemFilter.template('template-name') %}

{# Correct #}
{{ _api.app.items.template('template-name') %}

New API parameters

A few new API parameters have also been added. 

first - Retrieve just the first matched item.

slug - Retrieve the item that matches the URL slug value.

New API methods

We added some new API methods that can make it easier to get just one returned app item. They make it so that you don't have to use the limit(1) parameter anymore. They are ideal to use with the new slug parameter.

For all apps that support categories, a single category can be returned with the category API method.

For all apps that support tags, a single tag can be returned with the tag API method.

Below are the new app-specific methods organized by the app they are for. They accept the same parameters as the plural methods listed above.

App API Method
All apps supporting categories category
All apps supporting tags tag
App item
Blog post
Calendar event
Classifieds listing
Directory profile
Documents document
Employment job
Gallery item
Members profile
Real Estate agent
Real Estate property
Rental property
Rental propertyUnit
Store manufacturer
Store product
Trails badge
Trails trail

 

Below is an example showing how to get just one app item.

{% set item = _api.app.item.slug('url-slug-here') %}

{# The above is the same as #}
{% set item = _api.app.items.slug('url-slug-here').limit(1) %}

{# Although technically the above API wouldn't need the limit(1) since it's using a URL slug, which should only return one item. :) #}

Sign up for our newsletter to receive invaluable information about BranchCMS, web design & development.