BranchCMS Upgrades

Eric Tompkins
Apr 16, 2010

Pass Custom Parameters to Use in API Content Templates

The development of Aptuitiv Studio is mostly driven by the needs of our customers and recently a client had some special needs. We were working on a website for one of our partners and the section of the site we were working on was for staff profiles. We were using the Directory app for this one. The requirement that was giving some problems was that the design called for navigation that listed out each staff member.  We could have solved this by using the Navigation app and creating a new navigation menu for this section. However, if a staff member was added, changed or deleted then this navigation menu would also have to be updated. We thought it would be best if the navigation was built straight from the list of staff members. That was easily done using the Directory profileFilter API but a problem soon cropped up.

We had no way of knowing which navigation item should be highlighted as the current navigation item. The Navigation app normally takes care of this but we weren't using the Navigation app. We needed a way to tell the API to highlight a specific person when that person's page was being viewed.

Enter the topic of this blog post: custom parameters to use in API content templates.

We added the ability to pass through any value to the API call with the special apiParam parameter. This parameter should be setup as an array.  Below is an example of the full API call used.

{ap_api:directory:profileFilter templateId="1" sort[lastName]="asc" sort[firstName]="asc" apiParam[currentProfile]="{#id}"}

The "currentProfile" value is now available in the API content template under the apiParam variable as {#apiParam.currentProfile}.

This is a small update that probably won't get used too often, but it certainly does have its place and when it is used it has a big impact.

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