To retrieve everything related to a branch, to perform branch searches and generally build the template up, we need to work in our branches folder. Let’s start with the index file.
The branches index
A branches index route would simply be: http://www.agency_domain.com/branches. On our index page we can add the following code:
This construct is exactly the same as a properties loop seen before except we are referencing our branches collection as well as including a branch_small partial for each returned branch. A branch_small might look something like:
Map Zoom levels
If you need to manually set the zoom level of the branch map you can do so with the following snippet (replace 15 with any fallback zoom level you wish):
Note: You will also need to specify the map pan co-ordinates for the custom zoom level to work
Branch searching
If you’re building a portal or larger agency theme, you will pleased to know that users can search for your branches using our geo location database. This comes complete with a handy AJAX style auto suggest location based on the town or city the user enters. To get up and running, first we need to add our form:
Next where you branch results need to be, we have:
The output here will be an index of branches, but if we submit our form with a location, our branches controller will go off, fetch the results and display them in place of the index results.
Branch titles and pagination
Much like we saw earlier in the documentation with property results, it’s useful to output some titles and especially useful to output pagination if the branch results are on several pages. There’s a number of ways that you can deal with titles - here’s one such example:
The branches index results comes loaded with the same pagination figures and options we saw in the property results earlier. Here’s an example construct:
This might output something like:
By running various IF checks, we can essentially figure out whether there’s a next and/or previous page (for example) and format the output accordingly.
The branch show page
Wherever we have a Liquid tag that looks like {{ branch | url_for_branch}} or if the branch URL is called, the branch show page will get called into action. As with all of the subjects, the branch show page is simply titled show.liquid and lives in the branches folder.
The branch show page supports many of the things we saw on the property show page. To get the branch name we use the branch drop and name: {{branch.name}}. Moving on, we can then fetch the branch description:
Ff you wanted to display some staff profiles with links to full profiles, you could use something like:
#####Map Zoom levels
If you need to manually set the zoom level of the branch map you can do so with the following snippet (replace 15 with any fallback zoom level you wish):
Note: You will also need to specify the map pan co-ordinates for the custom zoom level to work
Displaying branch properties
The branch properties page is one where we can thankfully reuse our property loops and pagination figures as seen on the property results. If you would like to display all properties that belong to a branch with pagination, we’ll need a properties.liquid file within the branches folder. In it, add the path to your search results:
We can then link to the branch properties page using the following;
Branch recent sales and lettings
Here’s what a togglable sales tab and recent branch sales function looks like:
To get this up and running for lettings, just substitute any reference to sales for lettings.