homeflow_api 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9f6219febb52348410f680e1294a95684651356b
4
+ data.tar.gz: 91e652c2d1c743c2924449271e838a9aea11873d
5
+ SHA512:
6
+ metadata.gz: a70b03ea5f5bb684407678ba83b675b163399ddd3e692e49fe5243c71291c9458dd200f4054ac6a151f945a23796b71f47e75227c2a361205b78cb12bad9eeb2
7
+ data.tar.gz: f0a5716913edaf0f697f12517a189c4aec14ea24c3d0a73ccfac9fe0a0776037320becbcf724fa8c9a4bf44c116657652ed63ffd6bb7f19d0deecf651316a34a
data/homeflow_api.gemspec CHANGED
@@ -23,4 +23,3 @@ Gem::Specification.new do |s|
23
23
  s.files = `git ls-files`.split("\n")
24
24
  s.require_paths = ["lib"]
25
25
  end
26
-
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
data/index.html ADDED
@@ -0,0 +1,1405 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset='utf-8'>
5
+ <meta http-equiv="X-UA-Compatible" content="chrome=1">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
7
+ <link href='https://fonts.googleapis.com/css?family=Architects+Daughter' rel='stylesheet' type='text/css'>
8
+ <link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" media="screen">
9
+ <link rel="stylesheet" type="text/css" href="stylesheets/pygment_trac.css" media="screen">
10
+ <link rel="stylesheet" type="text/css" href="stylesheets/print.css" media="print">
11
+
12
+ <!--[if lt IE 9]>
13
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
14
+ <![endif]-->
15
+
16
+ <title>Homeflow api by homeflow</title>
17
+ </head>
18
+
19
+ <body>
20
+ <header>
21
+ <div class="inner">
22
+ <h1>Homeflow api</h1>
23
+ <h2></h2>
24
+ <a href="https://github.com/homeflow/homeflow_api" class="button"><small>View project on</small>GitHub</a>
25
+ </div>
26
+ </header>
27
+
28
+ <div id="content-wrapper">
29
+ <div class="inner clearfix">
30
+ <section id="main-content">
31
+ <h1>
32
+ <a name="the-homeflow-api" class="anchor" href="#the-homeflow-api"><span class="octicon octicon-link"></span></a>The Homeflow API</h1>
33
+
34
+ <p>Hi there and welcome to the Homeflow wiki.</p>
35
+
36
+ <p>Homeflow provides developers with everything they need to build exceptional property based websites. Within this Wiki we hope you will find all the information you need to get your agency or portal theme up and running.</p>
37
+
38
+ <p>You'll use the IDE you're familiar with plus all the developer tools you know and love such as: HTML, CSS, JavaScript and jQuery. You will make your own decisions on the plugins you or your customer requires and have complete design control over your new website from the word go.</p>
39
+
40
+ <p>As alluded to above, we're making the assumption that you're familiar with HTML, CSS etc. You will also need a basic working knowledge of Git and Liquid, though both are relatively simple to pick up as you go along.</p>
41
+
42
+ <p>Before we get started, there are three areas of the Homeflow API to be aware of as they will be mentioned throughout this documentation:</p>
43
+
44
+ <p>1) The Agency/Portal Admin<br>
45
+ 2) Hestia<br>
46
+ 3) Ctesius</p>
47
+
48
+ <p>You can consider The Agency and Portal Admin as the repository of all the information related to an agency or portal (essentially a CMS) - think properties, pages, content, images and more. Hestia (The Greek Goddess of the Heart) allows the querying of this information at lightning fast speeds. Finally Ctesius (The Greek God of Property) is our frontend application that is powered by Hestia. It includes an event management system, supports advanced property searching, user profiling and will support and augment the theme you will build. </p>
49
+
50
+ <p>All themes are developed using mostly HTML, CSS and JavaScript, but they also make use of the Liquid templating system, made popular by Shopify. Liquid sits in places of your code where dynamic content is required, such as property, agency, staff or user information.</p>
51
+
52
+ <p>We will explore all of the technologies mentioned above in much more detail later in the Wiki. In the meantime you can head straight over to the section you require using the menu on the right or move on to <a href="/homeflow/homeflow_api/wiki/ctesius#getting-started">Getting started</a>.</p>
53
+
54
+ <h1>
55
+ <a name="getting-started" class="anchor" href="#getting-started"><span class="octicon octicon-link"></span></a>Getting started</h1>
56
+
57
+ <p>Firstly we will need to initialise a Git repository for your theme on our platform and provide it with an API key so it can query Hestia and get the information it needs. You don't need to do anything here and it's a stage we will automate in the future. </p>
58
+
59
+ <p>Once we have done this we will create you an account on <code>Gitlab</code> (our internal Git platform) and you will receive an automatic email containing your login information. Before you can get to work on your theme, your will need to supply Gitlab with your <code>Public SSH key</code>. This is so you can clone and push/pull to and from your theme's repository. For information on how to fetch or generate your SSH key, visit <a href="https://help.github.com/articles/generating-ssh-keys#platform-mac">this link</a>. </p>
60
+
61
+ <p>This link will take you to the SSH section on Homeflow where you can paste in your key: <code>http://hades.homeflow.co.uk/keys</code>.</p>
62
+
63
+ <p>To clone your repository, open up a command prompt and <code>cd</code> to directory of your choice (but one that you won't forget and is easy to get to!) and run the following:</p>
64
+
65
+ <p><code>git clone &lt;link&gt;</code></p>
66
+
67
+ <p>Your Git clone URL will look something like: <code>git@hades.homeflow.co.uk:fdesign/pantani.git</code>.</p>
68
+
69
+ <p>By this point we should have provided you with a <code>staging</code> link so you/your team/your customer can view the development progress of the site. Once you have added your public key and you have successfully cloned your repository, we can now start to put your theme's folder structure together. </p>
70
+
71
+ <h2>
72
+ <a name="theme-folder-structure" class="anchor" href="#theme-folder-structure"><span class="octicon octicon-link"></span></a>Theme folder structure</h2>
73
+
74
+ <p>Ctesius themes use the standard Rails conventions for folder layouts. Don't worry if you're not familiar with Rails or this structure as an example theme folder structure can be seen below or found on the demo <a href="https://github.com/homeflow/stabilisers">Stabilisers theme</a>.</p>
75
+
76
+ <ul>
77
+ <li>theme_name<br><ul>
78
+ <li>agencies
79
+
80
+ <ul>
81
+ <li>index.liquid</li>
82
+ <li>show.liquid</li>
83
+ </ul>
84
+ </li>
85
+ <li>articles
86
+
87
+ <ul>
88
+ <li>index.liquid</li>
89
+ <li>show.liquid</li>
90
+ </ul>
91
+ </li>
92
+ <li>assets
93
+
94
+ <ul>
95
+ <li>images</li>
96
+ <li>javascripts</li>
97
+ <li>stylesheets
98
+
99
+ <ul>
100
+ <li>theme_styles.lcss - our LCSS file holds our styles just as a CSS file would</li>
101
+ </ul>
102
+ </li>
103
+ </ul>
104
+ </li>
105
+ <li>branches
106
+
107
+ <ul>
108
+ <li>_branches_list.ljson - a JSON view to list an array of branches</li>
109
+ <li>index.liquid</li>
110
+ <li>show.liquid</li>
111
+ </ul>
112
+ </li>
113
+ <li>home
114
+
115
+ <ul>
116
+ <li>home.liquid - the main homepage</li>
117
+ </ul>
118
+ </li>
119
+ <li>layouts
120
+
121
+ <ul>
122
+ <li>application.liquid - the main layout file which renders the other pages</li>
123
+ </ul>
124
+ </li>
125
+ <li>pages
126
+
127
+ <ul>
128
+ <li>show.liquid</li>
129
+ </ul>
130
+ </li>
131
+ <li>properties
132
+
133
+ <ul>
134
+ <li>_properties_list.ljson - a JSON view to list an array of properties</li>
135
+ <li>index.liquid</li>
136
+ <li>show.liquid</li>
137
+ </ul>
138
+ </li>
139
+ <li>staff
140
+
141
+ <ul>
142
+ <li>index.liquid</li>
143
+ <li>show.liquid</li>
144
+ </ul>
145
+ </li>
146
+ <li>user
147
+
148
+ <ul>
149
+ <li>new.liquid</li>
150
+ </ul>
151
+ </li>
152
+ </ul>
153
+ </li>
154
+ </ul><p>If your repository doesn't have these files and folders yet, add them in. Once done, make your first commit and push to your repository. We would recommend a Git GUI such as Tower for OSx or one of the freebies available for Linux such as Git Cola. If you're using Git via the command line, bring up a terminal, <code>cd</code> to you theme's root directory and run:</p>
155
+
156
+ <p><code>git commit -a -m 'Theme folders and files'</code></p>
157
+
158
+ <p>Then run:</p>
159
+
160
+ <p><code>git push origin master</code></p>
161
+
162
+ <p>This will add all of your modified files, commit them as well as push them to the remote repository. We can't view the site online just yet as there's nothing to render. Time to add some structure and content to our <code>application.liquid</code> file.</p>
163
+
164
+ <h2>
165
+ <a name="the-layout-file" class="anchor" href="#the-layout-file"><span class="octicon octicon-link"></span></a>The layout File</h2>
166
+
167
+ <p>Every page render starts at the layout, which is always found in <code>/layouts/application.liquid</code>. This file will contain the html, head, and body tags and will define the overall 'makeup' of your site.</p>
168
+
169
+ <p>Take a look at the source in the Stabilisers theme and you will see there's a few things to note. Firstly we link to the default styles and JavaScripts using our first bit of Liquid syntax:</p>
170
+
171
+ <pre><code> {{ "application" | javascript_include_tag }}
172
+ {{ "application" | stylesheet_link_tag }}
173
+ </code></pre>
174
+
175
+ <p>This will bring in all the default styles and some JavaScript libraries which form the basis of every Ctesius theme. As of the latest revision to this Wiki, they are:</p>
176
+
177
+ <ul>
178
+ <li>Bootstrap</li>
179
+ <li>jQuery - v1.9</li>
180
+ <li>jQuery Cycle - 3.0.3 (11-JUL-2013)</li>
181
+ <li>jQuery Nivo Slider</li>
182
+ <li>Backbone.js - 1.0.0</li>
183
+ <li>Underscore.js - 1.4.3</li>
184
+ <li>leaflet.js</li>
185
+ <li>Font Awesome</li>
186
+ <li>the Homeflow search and profile system</li>
187
+ </ul><p>You'll also notice that we make another call:</p>
188
+
189
+ <p><code>{{ "stabilisers" | theme_stylesheet_link_tag }}</code></p>
190
+
191
+ <p>There is a subtle different between the two Liquid directives in that the latter has a <code>theme_</code> directive and the other does not. When you add a theme stylesheet or theme JavaScript directive, the theme will expect the quoted LCSS file to reside in <code>/assets/stylesheets</code> (<code>/assets/javascripts</code> for JavaScript files). LCSS files are pretty much CSS files run through a Liquid filter. This enables us to customise the CSS easily for different sites. The directive without the theme pointer will load something from the core app.</p>
192
+
193
+ <p>Continuing with the layout file the next command you'll see is:</p>
194
+
195
+ <p><code>{% include 'layouts/js_templates' %}</code></p>
196
+
197
+ <p>This is the first include that we've seen. A bit like PHP includes, Liquid includes allow you include a partial template. This is excellent for including blocks that occur on several pages, or, as we'll see later, in Liquid for loops. Important point: partial names must be preceeded by an underscore <code>_</code>. When you call the partial however, no underscore is required though you must put the path in quotes.</p>
198
+
199
+ <p>The directive here pulls in the default JavaScript templates for the dynamically drawn user sections of the site. They are all overridable so you can design them as you need to. We'll expand more on these templates later.</p>
200
+
201
+ <p>Perhaps the most important section for the layout is the helper <code>content_for_layout</code>. This outputs the rendered results of the rest of the template.</p>
202
+
203
+ <p><code>{{ content_for_layout }}</code></p>
204
+
205
+ <p>In other words, all other template parts are like partials that get evaluated and loaded into this section.</p>
206
+
207
+ <p>Finally we need to boot the Ctesius system to handle searches, user profiles and so on. To do that we add the following function: </p>
208
+
209
+ <pre><code> &lt;script type="text/javascript"&gt;
210
+ $(document).ready(function(){
211
+ Ctesius.init()
212
+ });
213
+ &lt;/script&gt;
214
+ </code></pre>
215
+
216
+ <p>This needs to be used after any Ctesius events or config options are set. Some theme developers choose to add this function at the foot of application.liquid whereas others will add it to a theme JavaScripts file, include the directive at the bottom of it, then include the partial.</p>
217
+
218
+ <h2>
219
+ <a name="building-up-the-layout" class="anchor" href="#building-up-the-layout"><span class="octicon octicon-link"></span></a>Building up the layout</h2>
220
+
221
+ <p>Other than the Liquid directives in the head section, the <code>content_for_layout</code> we saw earlier and the Ctesius boot, the <code>application.liquid</code> file is constructed just the same as a regular web page - add your classes and IDs, divs and CSS in the normal way and style them up using your theme CSS. Be sure to to put it in the stylesheets directive and make sure the names match up:</p>
222
+
223
+ <p><code>{{ "your_theme_css" | theme_stylesheet_link_tag }}</code></p>
224
+
225
+ <p>We talk more about images in the <a href="./assets">Working with images and assets</a> section, but for now add your agency's/portal's logo into the <code>/assets/images</code> folder and reference it in your application markup as follows:</p>
226
+
227
+ <p><code>&lt;img src="{{'your_image.png' | theme_image_url : "70x70" }}" /&gt;</code></p>
228
+
229
+ <p>You will notice that we have added a Liquid directive straight into the source of the image. Liquid will expect there to be an image of the name and extension quoted in your theme images folder (<code>/assets/images</code>). Also note that we've added an arguement on the end to ask Liquid to resize the image on the server, then send it to the browser - neat.</p>
230
+
231
+ <h2>
232
+ <a name="running-your-theme" class="anchor" href="#running-your-theme"><span class="octicon octicon-link"></span></a>Running your theme</h2>
233
+
234
+ <p>Now that you have hopefully added your HTML, some CSS and some images, it's time to see the results. Commit and push your changes and observe the <code>staging</code> URL we sent to you. It will look something like:</p>
235
+
236
+ <p>Agencies: <code>http://agency_homeflow_domain.agent.staging.homeflow.co.uk</code><br>
237
+ Portals: <code>http://portal_homeflow_domain.search.staging.homeflow.co.uk</code></p>
238
+
239
+ <p>Hopefully you will see the result in the browser.</p>
240
+
241
+ <h2>
242
+ <a name="building-up-the-application-and-home-page" class="anchor" href="#building-up-the-application-and-home-page"><span class="octicon octicon-link"></span></a>Building up the application and home page</h2>
243
+
244
+ <p>At this point we can start to think about the elements that will be consistent to every page and those that will just reside on the home page. Those that are consistent to every page need to reside in the application.liquid file and would probably include:</p>
245
+
246
+ <ul>
247
+ <li>The header</li>
248
+ <li>The navigation menu</li>
249
+ <li>The footer</li>
250
+ </ul><h2>
251
+ <a name="the-header-with-an-agency-or-portal-logo" class="anchor" href="#the-header-with-an-agency-or-portal-logo"><span class="octicon octicon-link"></span></a>The header with an agency or portal logo</h2>
252
+
253
+ <p>A header would probably consist of the agency or portal logo, so let's take a first foray into the Agency or Portal admin, add the logo, then pull it out and plug it into the source using Liquid. Note that if you'd rather just add or keep your logo in <code>/assets/images</code> that's absolutely fine.</p>
254
+
255
+ <p>To get to your admin, you use a link similar to the two links outlined before:</p>
256
+
257
+ <p>Agencies: <code>http://agency_homeflow_domain.homeflow.co.uk/admin</code><br>
258
+ Portals: <code>http://portal_homeflow_domain.portal.homeflow.co.uk/admin</code></p>
259
+
260
+ <p>We'll assume you have been provided with your login.</p>
261
+
262
+ <p>In the agency admin, go to <code>Website/Appearance/Logos</code> and upload your logo<br>
263
+ In the portal admin, go to <code>Configure/Appearance/Logos</code> and upload your portal logo.</p>
264
+
265
+ <p>Now in your source, within your header tags or header div tags, add:</p>
266
+
267
+ <p>Agency:<br><code>&lt;img src="{{ agency.logo | url_for_agency_logo }}" alt="{{agency.name}} logo" /&gt;</code></p>
268
+
269
+ <p>Portal:<br><code>&lt;img src="{{ portal.website_logo | url_for_portal_logo }}" alt="{{portal.name}}" /&gt;</code></p>
270
+
271
+ <p>There's a couple of new things here - the first is we need a <code>key</code> when referencing an agency or portal logo (and many other things as we'll see) and we're using the agency and portal Liquid name tag to fill in the alt attribute of the image. As you become more experienced with your template(s) you will find there's some useful and sometimes innovative ways you can use tags.</p>
272
+
273
+ <h2>
274
+ <a name="the-navigation-menu" class="anchor" href="#the-navigation-menu"><span class="octicon octicon-link"></span></a>The navigation menu</h2>
275
+
276
+ <p>The navigation is another area where you have complete freedom of development - if you wanted to hardcode your menu and add/remove new or old items as they come along, that's absolutely fine. If however, you'd prefer to add the navigation tree to the agency admin and extract them using Liquid, that's fine too. Generally speaking portals add their menu to their source whereas theme designers or agency sites will tend to code the menu using Liquid, as their theme can then be deployed for multiple agencies.</p>
277
+
278
+ <p>Let's assume for now you would like to query the agency admin and therefore Hestia for the menu and, if it has been added, its sub-menu counterpart.</p>
279
+
280
+ <p>To start head over to your agency admin. Reminder: <code>http://agency_homeflow_domain.homeflow.co.uk/admin</code></p>
281
+
282
+ <p>Then go to <code>Website/Navigation</code>. From here you can drag in menu items for existing pages or create custom links, e.g. to the <code>/branches</code> page for example. Once you've got your primary menu items, you can then edit each one and add sub-menu items.</p>
283
+
284
+ <p>Here's a code construct that would retrieve the primary menu items:</p>
285
+
286
+ <pre><code>{% assign primary_menu = 'primary' | site_menu %}
287
+ &lt;ul class="top-level"&gt;
288
+ {% for menu_item in primary_menu.items %}
289
+ &lt;li class="top-level-li"&gt;
290
+ &lt;a href="{{ menu_item.url }}"&gt;{{ menu_item.name }}&lt;/a&gt;
291
+ &lt;/li&gt;
292
+ {% endfor %}
293
+ &lt;/ul&gt;
294
+ </code></pre>
295
+
296
+ <p>Here we can see two new things: an <code>assign</code> statement and a Liquid <code>for loop</code>.</p>
297
+
298
+ <p>The <code>assign</code> statement allows you to assign something to a Liquid variable. This can be as simple as a string or result of some evaluation. Also, as seen above, you can assign Liquid objects to a variable for looping and other purposes.</p>
299
+
300
+ <p>And the good old <code>for loop</code>. You'll probably be familiar with the <code>for loop</code> from other programming languages and Liquid's variant is very simple to use - loop through an object and you can write out its attributes as required.</p>
301
+
302
+ <p>So what about a nested menu to support dropdrowns? Here's a code construct that will satisfy this requirement:</p>
303
+
304
+ <pre><code>&lt;ul class="top-level"&gt;
305
+ {% assign primary_menu = 'primary' | site_menu %}
306
+ {% for menu_item in primary_menu.items %}
307
+ &lt;li class="top-level-li"&gt;
308
+ &lt;a class="navigation" href="{{ menu_item.url }}"&gt;{{ menu_item.name }}&lt;/a&gt;
309
+ {% if menu_item.items != empty %}
310
+ &lt;ul class="subnav"&gt;
311
+ {% for sub_menu_item in menu_item.items %}
312
+ &lt;li&gt;
313
+ &lt;a href="{{sub_menu_item.url}}"&gt;{{sub_menu_item.name }}&lt;/a&gt;
314
+ &lt;/li&gt;
315
+ {% endfor %}
316
+ &lt;/ul&gt;
317
+ {% endif %}
318
+ &lt;/li&gt;
319
+ {% endfor %}
320
+ &lt;/ul&gt;
321
+ </code></pre>
322
+
323
+ <p>There's nothing new here but let's step through what's going on. Firstly we do our <code>assign</code> then we loop through the <code>primary menu items</code> and output an <code>li</code> and <code>anchor</code> for each. Next we check whether the menu item we're looping over has any items within it by doing an <code>if not empty</code> test - <code>empty</code> is a handy Liquid check to see if a variable has been initialised. If so, we output another unordered list and then we loop through the sub menu items of that menu item. We then output an <code>li</code> and <code>anchor</code> for each.</p>
324
+
325
+ <p>Finally we close off the <code>if</code> and <code>for loop</code> using the appropriate end Liquid statements.</p>
326
+
327
+ <h2>
328
+ <a name="the-carousel" class="anchor" href="#the-carousel"><span class="octicon octicon-link"></span></a>The carousel</h2>
329
+
330
+ <p>Many agency sites and indeed portals have what we refer to as a <code>carousel</code> on their home page. This is a gallery of images with text overlays designed to give the user an attractive initial presentation and to give your site the 'wow' factor. At the time of writing, many theme developers are using full width images within their carousel as well as responsive images to cater for different viewports.</p>
331
+
332
+ <p>Your first port of call is to head to the carousel section within the agency or portal admin. You can find that under <code>Website/carousel</code>. Don't worry about the settings for now but instead go straight to <code>Add item</code>. Keep the standard option selected and upload your background image, add a title, a standfirst (the chunk of accompanying text) and a link if required. The minimum you'll want is an image and standfirst.</p>
333
+
334
+ <p>Now return to you theme and the <code>home/home.liquid</code> file. This is one place, and a logical one, where we can add our carousel code:</p>
335
+
336
+ <pre><code>&lt;ul&gt;
337
+ {% for item in agency.carousel_items %}
338
+ &lt;li style="background-image:url({{item.image | url_for_generic_image}})"&gt;
339
+ &lt;div class="slide-content"&gt;
340
+ &lt;h2&gt;
341
+ {% if item.link_url != empty %}
342
+ &lt;a href="{{ item.link_url }}" class="link_url" title="{{item.title}}"&gt;
343
+ {% endif %}
344
+ {{item.title}}
345
+ {% if item.link_url != empty %}
346
+ &lt;/a&gt;
347
+ {% endif %}
348
+ &lt;/h2&gt;
349
+ &lt;p&gt;
350
+ {{item.standfirst | truncate: 200}}
351
+ &lt;/p&gt;
352
+ &lt;/div&gt;
353
+ &lt;/li&gt;
354
+ {% endfor %}
355
+ &lt;/ul&gt;
356
+ </code></pre>
357
+
358
+ <p>There are numerous ways you can use the carousel - some themes have a small photo box whereas others go full width with the photos. In the example above, we are going full width with our carousel image set as a background against the <code>li</code> for each carousel item using a for loop. As you can see, we check if the <code>link_url</code> is empty and if not, we wrap out title with the link URL. We then output our standfirst and in this case we truncate it to two hundred characters (more on truncate in a bit). Note that we could run a check on standfirst but here we're assuming a standfirst has been entered for each carousel item.</p>
359
+
360
+ <p>Whilst we're covering the carousel and <code>home.liquid</code> it's worth pointing out that your carousel doesn't have to reside in <code>home.liquid</code>. Many front pages are split into different sections and sometimes it doesn't make sense for everything that is featured on the home page to be in home (by the way the <code>home.liquid</code> file is automatically included into the <code>{{content_for_layout}}</code> yield when on the site's root). On occasions where we want to include content on the home page but you'd rather add it to <code>application.liquid</code>, you can use the following statement:</p>
361
+
362
+ <pre><code>{% if page.controller_name == 'home' %}
363
+ *content*
364
+ {% endif %}
365
+ </code></pre>
366
+
367
+ <p>And for a handy reference as to what controller is being used, you can add the controller and action as a class to the body tag then inspect the source:</p>
368
+
369
+ <p><code>&lt;body class="{{page.controller_name}} {{page.action_name}}"&gt;</code></p>
370
+
371
+ <h2>
372
+ <a name="the-footer" class="anchor" href="#the-footer"><span class="octicon octicon-link"></span></a>The footer</h2>
373
+
374
+ <p>Again, the footer is an area where you can hardcode in your design and content, or you can manage the content using the Agent/Portal admin and the <code>content chunks</code> we have made available. <code>Content chunks</code> are well-known content areas that get used on all sites - e.g. a header, footer, sidebar and so on. If we add some content to the footer chunk we can then render it out. </p>
375
+
376
+ <p>Agencies: <code>Website/Content</code><br>
377
+ Portals: <code>Configure/Content/Pages</code></p>
378
+
379
+ <p>Both content chunk sections are then on the left. Checkout the <code>Site footer</code> chunk, add some filler content for now then save it.</p>
380
+
381
+ <p>Now, where you want to render the chunk in your source (if it's the footer then most likely the <code>application.liquid</code> page), use the following code:</p>
382
+
383
+ <pre><code>{% content_block 'site_footer' %}
384
+ {% if content_block %}
385
+ {{content_block}}
386
+ {% endif %}
387
+ {% endcontent_block %}
388
+ </code></pre>
389
+
390
+ <p>This will render your chunk. Note that you can add HTML syntax into the chunk using the MCE editor.</p>
391
+
392
+ <h1>
393
+ <a name="working-with-property-searches" class="anchor" href="#working-with-property-searches"><span class="octicon octicon-link"></span></a>Working with property searches</h1>
394
+
395
+ <p>This part of the Wiki will explore how we construct the forms and display search results - arguably the most important aspect of a property search website.</p>
396
+
397
+ <h2>
398
+ <a name="constructing-a-property-search-form" class="anchor" href="#constructing-a-property-search-form"><span class="octicon octicon-link"></span></a>Constructing a property search form</h2>
399
+
400
+ <p>Somewhere in your application layout file you're likely to have a property search form. There are a myriad of filter options you can show and a couple of methods of searching which we'll explore later, but for now is a basic form is below. Note we have stripped any classes or styling to keep it as simple as possible:</p>
401
+
402
+ <pre><code>&lt;form action='/search' id='search' method='get' /&gt;
403
+ &lt;input type="radio" name="channel" value="sales" id="buy"&gt; &lt;label&gt;For Sale&lt;/label&gt;
404
+ &lt;input type="radio" name="channel" value="lettings" id="let"&gt; &lt;label&gt;To Let&lt;/label&gt;
405
+ &lt;button onclick="Ctesius.Actions.submitSearchForm(); return false;" type="submit"&gt;Search&lt;/button&gt;
406
+ &lt;/form&gt;
407
+ </code></pre>
408
+
409
+ <p>When the <code>Ctesius.Actions.submitSearchForm()</code> is called the system will evaluate every form on the page looking for elements with specified IDs and use them to construct a search. Here the only fields the user can select are whether it's a sales or lettings search. The results that will be shown with this type of form will be an <code>index</code> of an agency or portal's properties - this is where our <code>/properties/index.liquid</code> file comes in. More on that in the <a href="/homeflow/homeflow_api/wiki/ctesius#displaying-search-results">Displaying search results</a> section.</p>
410
+
411
+ <p>Expanding on our first example, we can now add two addition fields that allow the user to type in a location. If it's recognised in our database, we'll load a number of suggested locations for the user to select. The hidden place ID field is a lookup reference for our system and is required in the source. With just two extra fields your property search will be completely supported by our geo location database:</p>
412
+
413
+ <pre><code>&lt;input type='hidden' id ='place_id' name='place_id' value='{{place_id}}' /&gt;
414
+ &lt;input placeholder='Town or Postcode' type="text" id='location' name="location" value="{{location_field}}"/&gt;
415
+ </code></pre>
416
+
417
+ <p>Now let's add some beds and price bracket options:</p>
418
+
419
+ <pre><code>&lt;select id="min_beds" name='min_beds'&gt;
420
+ &lt;option value="" title="Min beds"&gt;Beds min&lt;/option&gt;
421
+ &lt;option value="1" title="1 Bed"&gt;1 bed&lt;/option&gt;
422
+ &lt;option value="2" title="2 Beds"&gt;2 beds&lt;/option&gt;
423
+ &lt;/select&gt;
424
+ &lt;select id="max_beds" name='max_beds'&gt;
425
+ &lt;option value="" title="Max beds"&gt;Beds max&lt;/option&gt;
426
+ &lt;option value="1" title="1 Bed"&gt;1 bed&lt;/option&gt;
427
+ &lt;option value="2" title="2 Beds"&gt;2 beds&lt;/option&gt;
428
+ &lt;/select&gt;
429
+ &lt;select id="min_price" name='min_price'&gt;
430
+ &lt;option value="" title="Min price"&gt;Price min&lt;/option&gt;
431
+ &lt;/select&gt;
432
+ &lt;select id="max_price" name='max_price'&gt;
433
+ &lt;option value="" title="Max price"&gt;Price max&lt;/option&gt;
434
+ &lt;/select&gt;
435
+ </code></pre>
436
+
437
+ <p>This is probably all self-explanatory. One thing to note is that the IDs and names are important so we can process the form.</p>
438
+
439
+ <p>Finally let's add a property type selector:</p>
440
+
441
+ <pre><code>&lt;select id="type" name='type'&gt;
442
+ &lt;option value="" title="Property type"&gt;Property type&lt;/option&gt;
443
+ {{ agency | tag_dropdown_list }}
444
+ &lt;/select&gt;
445
+ </code></pre>
446
+
447
+ <p>You will note a snippet of Liquid here. This code takes some pre-selected types in the Agency or Portal Admin and outputs them as options.</p>
448
+
449
+ <p>If it were a portal, you would use the portal tag instead:</p>
450
+
451
+ <p><code>{{ portal | tag_dropdown_list }}</code></p>
452
+
453
+ <p>Another option is to simply specify the types - the names here must match what we use as type references:</p>
454
+
455
+ <pre><code>&lt;option value="cottage" title="cottage"&gt;Cottage&lt;/option&gt;
456
+ &lt;option value="farmhouse" title="farmhouse"&gt;Farmhouse&lt;/option&gt;
457
+ &lt;option value="townhouse" title="townhouse"&gt;Townhouse&lt;/option&gt;
458
+ </code></pre>
459
+
460
+ <p>Again you can style the form and position it in anyway you choose. Let's move on and see how we deal with property search results.</p>
461
+
462
+ <h2>
463
+ <a name="displaying-search-results" class="anchor" href="#displaying-search-results"><span class="octicon octicon-link"></span></a>Displaying search results</h2>
464
+
465
+ <p>After the form has been submitted, Ctesius and Hestia will go off an fetch the results - normally ten per page though this is configurable. A JSON response is returned and Liquid loops through and displays the results.</p>
466
+
467
+ <p>The first file we will want to get up and running is the <code>properties/index.liquid</code> file, which is located in the <code>properties</code> folder. The index displays every property belonging to an agency or portal. All searches are channel based so an index could show all sales or all lettings. On the whole the index will check whether the <code>properties</code> JSON is empty and if not, it will then include a <code>_results.liquid</code> partial, which is the main body of code that we'll be working with.</p>
468
+
469
+ <p>So the code could look something like this:</p>
470
+
471
+ <pre><code>{% if properties == empty %}
472
+ &lt;h4&gt;Sorry, we couldn't find any properties for this search.&lt;/h4&gt;
473
+ {% else %}
474
+ {% include 'search/results' %}
475
+ {% endif %}
476
+ </code></pre>
477
+
478
+ <p>Note that in our example above we've put our <code>results</code> partial in a <code>search</code> sub-folder. You don't have to do this and your <code>results</code> partial could reside in the <code>properties</code> folder if you wish.</p>
479
+
480
+ <p>Our <code>results</code> partial will probably include top and bottom pagination, top and/or bottom search statistics, alternative view types (list, map, grid, etc) and of course the Liquid loop that displays the properties. Note that one, more or indeed all of the above can be partials so we can re-use them if necessary.</p>
481
+
482
+ <h2>
483
+ <a name="the-properties-loop" class="anchor" href="#the-properties-loop"><span class="octicon octicon-link"></span></a>The properties loop</h2>
484
+
485
+ <p>Since Liquid for loops can include a partial for each property it makes sense to include a tried, tested and mananageble partial of code for each property. We refer to this partial as <code>_property_small.liquid</code>. </p>
486
+
487
+ <p>Here's what our for loop looks like:</p>
488
+
489
+ <pre><code>{% for property in properties %}
490
+ {% include "properties/property_small" %}
491
+ {% endfor %}
492
+ </code></pre>
493
+
494
+ <p>As you can see we loop through the properties array and include the <code>_property_small</code> partial for each one. Let's now take a look at what a sample <code>_property_small.liquid</code> could look like:</p>
495
+
496
+ <pre><code>&lt;div id="property_{{property.property_id}}" class="property-small"&gt;
497
+ {{ property | photo_overlay }}
498
+ &lt;a href="{{property | url_for_property}}"&gt;
499
+ &lt;img src="{{ property.photos.first | url_for_property_asset: "176x133" }}"&gt;
500
+ &lt;/a&gt;
501
+ &lt;a href="{{property | url_for_property}}"&gt;
502
+ {{property.display_address | truncate : 60}}
503
+ &lt;/a&gt;
504
+ &lt;p&gt;{{property.price}}&lt;/p&gt;
505
+ &lt;p&gt;{{property.short_description | truncate : 185}}&lt;/p&gt;
506
+ &lt;p&gt;&lt;a href="{{property | url_for_property}}"&gt;Full details&lt;/a&gt;&lt;/p&gt;
507
+ &lt;/div&gt;
508
+ </code></pre>
509
+
510
+ <p>Let's step through this. As you can see, we need to wrap each set of results in an ID or class container and we'll need to style up the elements so it renders nicely on a row. We'll assume you are okay with that and explain the Liquid. </p>
511
+
512
+ <p>Firstly, the ID of the div is <code>property_{{property.property_id}}</code>. As you can imagine, every property in our system gets assigned a numerical ID, and it's this ID that's used in URL and for other functions on the theme and in the backend. For now, we've outputted the ID so we can use our <code>Save to shortlist</code> function - more on that later.</p>
513
+
514
+ <p>The next tag <code>{{ property | photo_overlay }}</code> outputs the property status in the form of a sash image banner, or a custom banner of your choice. You can get to this custom images section via your agency or portal admin with the following link: <code>/configure/website/appearance/custom_images</code>.</p>
515
+
516
+ <p>The next piece of Liquid is: <code>{{ property.photos.first | url_for_property_asset: "176x133" }}</code>. As you might imagine, this looks at the photos array and gets the link of the first one for use in the image source. We then use the <code>url_for_property_asset</code> key and we pass in a size in pixels. As mentioned before, Liquid will resize the image on the server and send it to the browser.</p>
517
+
518
+ <p>A tag that's used numerous times in this code, as well as on many of the property related pages; <code>{{property | url_for_property}}</code> outputs the relative address to the property in question.</p>
519
+
520
+ <p>The next tag is <code>{{property.display_address | truncate : 60}}</code>. This tag outputs the display address of the property, which is the address as it comes in from the agency or portal feeds. A new arguement seen here is <code>truncate</code>. This is a very useful Liquid function, which is particularly useful when curtailing long addresses, descriptions and so on - just pass in the number of characters you want to keep. Another useful truncate function is <code>truncatewords: 20</code>. This does what it says on the tin.</p>
521
+
522
+ <h2>
523
+ <a name="handling-locations-and-postcodes" class="anchor" href="#handling-locations-and-postcodes"><span class="octicon octicon-link"></span></a>Handling locations and postcodes</h2>
524
+
525
+ <p>So far we have a basic properties index page and hopefully a set of results using the properties loop. How then, do we deal with locations like counties and towns as well as postcodes? This is where our include partial <code>search/_results.liquid</code> comes into its own. All we need to do is add three subfolders in the root directory: <code>locations</code>, <code>counties</code> and <code>postcodes</code>. Within these folders we simply need a <code>show.liquid</code> file and inside this file we add <code>{% include 'search/results' %}</code>. This will use our search results partial for the location searches - great. W now need to do now is make sure our page headings reflect the search that has been carried out. We may as well look at pagination whilst we're at it, too...</p>
526
+
527
+ <h2>
528
+ <a name="headings-and-pagination" class="anchor" href="#headings-and-pagination"><span class="octicon octicon-link"></span></a>Headings and pagination</h2>
529
+
530
+ <p>Headings need to reflect the search the user has carried out or it should output a very general statement if it's an index search. There's other considerations here; for instance if it is a county or postcode seach and so on. Some developers choose to add pagination statistics and pagination navigation together with search and location information, whereas others choose to seperate the two - you are free to find whatever suits you/your client. Note that the code below would be in <code>search/_results.liquid</code>. Here's an example heading:</p>
531
+
532
+ <pre><code>&lt;h1&gt;
533
+ {{search.dictionary.general_collective | capitalize}}
534
+ {{search.dictionary.preposition}}
535
+ {% if location %}in {{location.name}}{% endif %}
536
+ &lt;/h1&gt;
537
+ </code></pre>
538
+
539
+ <p>This could output something like: </p>
540
+
541
+ <p><code>Houses for sale in Walton on Thames</code></p>
542
+
543
+ <p>The <code>general_collective</code> is the property type, the <code>preposition</code> is the channel (sales or lettings) and finally we do a <code>location</code> test and output the <code>in</code> and <code>{{location.name}}</code> if it comes back as true. Let's look at another example:</p>
544
+
545
+ <pre><code>{{pagination.from_record}} to {{pagination.to_record}} of {{pagination.total_count}}
546
+ Properties found
547
+ {% if location %}
548
+ in {{location.name}}
549
+ {% endif %}
550
+ {% if pagination.has_prev_page %}
551
+ | &lt;a href="{{pagination.previous_page_link}}" class="pagination_prev"&gt;
552
+ Previous {{pagination.page_size}}
553
+ &lt;/a&gt;
554
+ {% endif %}
555
+ {% if pagination.has_next_page %}
556
+ | &lt;a href="{{pagination.next_page_link}}" class="pagination_next"&gt;
557
+ Next {{pagination.page_size}}
558
+ &lt;/a&gt;
559
+ {% endif %}
560
+ </code></pre>
561
+
562
+ <p>This might output something like: </p>
563
+
564
+ <p><code>1 to 12 of 31 Properties found in Walton on Thames | Next 12</code></p>
565
+
566
+ <p>This example starts with the <code>from_record</code> - if your page size is ten (which is the default) then this will go <code>1</code>, <code>11</code>, <code>21</code> etc. We then output the <code>to_record</code>, which again, if we're going up in tens, this would be <code>10</code>, <code>20</code>, <code>30</code> etc. We then output <code>{{pagination.total_count}}</code>, which outputs the item count. </p>
567
+
568
+ <p>Our next segment of code is two if statements that will output next and previous buttons or links if they are required. As you can see, we can get the next and previous links using the appropriate Liquid syntax as well as a handle on the page size, which is most likely going to be ten, but could be twelve, fourteen or whatever you or your client requires.</p>
569
+
570
+ <h2>
571
+ <a name="more-on-pagination" class="anchor" href="#more-on-pagination"><span class="octicon octicon-link"></span></a>More on pagination</h2>
572
+
573
+ <p>Ctesius ships with a <code>for pagination</code> function. If you've ever used Google before, and let's face it, who hasn't, then you'll be familiar with the pages before and after pagination they utilise at the foot of the search results.</p>
574
+
575
+ <p>This function takes a couple of arguements: <code>previous</code> and <code>after</code>.</p>
576
+
577
+ <p>These arguements allow you to define how many trailing and remaining pages to show. Here's the code:</p>
578
+
579
+ <pre><code> {% unless pagination.page_count == 1 %}
580
+ &lt;ul&gt;
581
+ {% if pagination.has_prev_page %}
582
+ {% if pagination.page_count &gt; 2 %}
583
+ &lt;li&gt;&lt;a href='{{pagination.first_page_link}}'&gt;&amp;lt; First&lt;/a&gt;&lt;/li&gt;
584
+ {% endif %}
585
+ {% endif %}
586
+ {% for_pagination pagination previous: 4 after : 4 %}
587
+ &lt;li&gt;
588
+ &lt;a href="{% if pagination_item.page_number == pagination.current_page %}#
589
+ {% else %}{{pagination_item.link}}{% endif %}"
590
+ {% if pagination_item.page_number == pagination.current_page %} class='s'{% endif %}&gt;
591
+ {{pagination_item.page_number}}&lt;/a&gt;
592
+ &lt;/li&gt;
593
+ {% endfor_pagination %}
594
+ {% if pagination.has_next_page and pagination.current_page != pagination.page_count %}
595
+ {% if pagination.page_count &gt; 2 %}
596
+ &lt;li&gt;
597
+ &lt;a href='{{pagination.last_page_link}}'&gt;Last &amp;gt;&lt;/a&gt;
598
+ &lt;/li&gt;
599
+ {% endif %}
600
+ {% endif %}
601
+ &lt;/ul&gt;
602
+ {% endunless %}
603
+ </code></pre>
604
+
605
+ <p>We start with the first <code>unless</code> statement we've seen. The <code>unless</code> statement will continue to output the code between the tags unless a certain condition is met. Here if page count is one, then we don't want to try and output the whole for block (incidentally this could be changed to an <code>if/else</code> and we could output the first page number to signify there's only one page). Next we use a couple of statments we've already seen and a Liquid tag we've not - <code>{{pagination.first_page_link}}</code> outputs the first page link.</p>
606
+
607
+ <p>Next we get into our for loop. First we give it a reference and then <code>previous: 4 after : 4</code>, meaning we want four trailing pages and four forthcoming pages (if they're available). The body of the for loop outputs the appropriate <code>li anchor</code> code for each. The final block in this code does a couple of checks to make sure there's pages remaining before outputting a helper <code>last</code> page link. We then close off our if statements and unless statements in the usual way.</p>
608
+
609
+ <h2>
610
+ <a name="togglable-areas" class="anchor" href="#togglable-areas"><span class="octicon octicon-link"></span></a>Togglable areas</h2>
611
+
612
+ <p>The core <code>application javascript include</code> comes with a JavaScript toggle system that can show and hide different <code>tabs</code> on a click. This is useful when working with different views and, as we will see later, it is also very useful on the <code>property show</code> page.</p>
613
+
614
+ <p>There are at least three well defined view types for the results page. They are <code>list</code>, <code>grid</code> and <code>map</code>. Here's what the code might look like:</p>
615
+
616
+ <pre><code>&lt;div id='togglable_list' class='togglable_area'&gt;
617
+ {% include 'properties/properties_list' %}
618
+ &lt;/div&gt;
619
+ &lt;div id="properties_grid_toggle_view" class="hidden togglable_area"&gt;
620
+ {% include 'properties/properties_grid' %}
621
+ &lt;/div&gt;
622
+ &lt;div id='togglable_map' class='togglable_area hidden'&gt;
623
+ {% include 'properties/pagination_for_map' %}
624
+ &lt;div id='draggable_map_view'&gt;&lt;/div&gt;
625
+ &lt;/div&gt;
626
+ </code></pre>
627
+
628
+ <p>Then to link to the views, we simply use the hash reference in the anchor like so:</p>
629
+
630
+ <pre><code>&lt;li&gt;&lt;a href="#home" class="active"&gt;LIST&lt;/a&gt;&lt;/li&gt;
631
+ &lt;li&gt;&lt;a href="#grid"&gt;GRID&lt;/a&gt;&lt;/li&gt;
632
+ &lt;li&gt;&lt;a href="#map"&gt;MAP&lt;/a&gt;&lt;/li&gt;
633
+ </code></pre>
634
+
635
+ <p>Note that <code>#home</code> correlates to the default list view.</p>
636
+
637
+ <h2>
638
+ <a name="working-with-the-map-view" class="anchor" href="#working-with-the-map-view"><span class="octicon octicon-link"></span></a>Working with the map view</h2>
639
+
640
+ <p>Ctesius comes loaded with maps for property results, individual properties, branches and so on. A draggable map is at your disposal for property results. The draggable map view can be placed on the map tab outlined above and can also update the property results on the fly based on the user dragging or zooming. To get the map up and running, all you need to do is add the <code>draggable_map_view</code> div to your tab and supply it with a height and a width in your CSS:</p>
641
+
642
+ <p><code>&lt;div id='draggable_map_view'&gt;&lt;/div&gt;</code></p>
643
+
644
+ <p>Given that we're allowing the user to zoom and drag, it would be useful to have a dialogue of the current properties that are on display. It would also be useful to update this when the user interacts with the map. With Ctesius's built in event system, we can do just that.</p>
645
+
646
+ <p>Above the <code>draggable_map_view</code> div, you will see we have an include for map pagination. This is where we can add any map related dialogue we have. In our example below it's actually very little:</p>
647
+
648
+ <pre><code>&lt;span id='map_info'&gt;&lt;/span&gt;
649
+ {% include 'properties/pagination_links' %}
650
+ </code></pre>
651
+
652
+ <p>Here we have an empty div ready to be populated with our dynamic map information and we have a partial to include the list, grid and map links that are common to all of the views. All we need to add to get the map information is two <code>Ctesius events</code>:</p>
653
+
654
+ <pre><code>&lt;script&gt;
655
+ Ctesius.registerEvent('before_draggable_map_updated',function(){
656
+ $('#map_info').html('Updating map...')
657
+ });
658
+
659
+ Ctesius.registerEvent('draggable_map_updated',function(res){
660
+ $('#map_info').html('Showing ' + res.properties.length + ' of ' + res.pagination.total_count + ' properties. Zoom in or drag the map to see more.' )
661
+ });
662
+ &lt;/script&gt;
663
+ </code></pre>
664
+
665
+ <p>Ctesius <code>kicks</code> events throughout the execution of a theme that we can conveniently get a handle on and perform some kind of action. In our example above, we register a callback function to execute when our draggable map events are kicked. By doing this we can add some nice feedback to the user. You can add these functions anywhere you like though many developers add them to the <code>js_event_registers</code> partial, which resides in the <code>layouts</code> folder.</p>
666
+
667
+ <h2>
668
+ <a name="working-with-grid-views" class="anchor" href="#working-with-grid-views"><span class="octicon octicon-link"></span></a>Working with grid views</h2>
669
+
670
+ <p>At the time of writing many agencies are integrating grid views into their property results. Grid views can sometimes produce a better visual offering than traditional list views and of course offers the user a degree of presentation flexibility. The easiest way to get up and running with a grid view is to have a <code>properties_grid</code> partial. Within this partial there is a second properties loop:</p>
671
+
672
+ <pre><code>% for property in properties %}
673
+ {% include 'properties/property_grid' %}
674
+ {% endfor %}
675
+ </code></pre>
676
+
677
+ <p>The partial <code>property_grid</code> then contains your individual grid view syntax. Since we're running another properties loop you might be forgiven to thinking we're fetching the properties again. Actually what we're doing is processing the same JSON that was returned from list view, so there is little or no overhead.</p>
678
+
679
+ <h2>
680
+ <a name="saving-properties-to-a-shortlist" class="anchor" href="#saving-properties-to-a-shortlist"><span class="octicon octicon-link"></span></a>Saving properties to a shortlist</h2>
681
+
682
+ <p>A common feature on property websites is saving properties to a semi or permanent storage with the appropriate widgets to link to or add/remove properties as the user sees fit. This kind of function is extremely useful on portals, but is also a nice feature for agencies to have. </p>
683
+
684
+ <p>Our first port of call is to use our first <code>override</code> partial so far. An override is simply a partial well-known to Ctesius that's in the <code>core</code> app ready for use. Sometimes core files can be used without needing to override them but in this instance we'll assume you want to modify the layout or at least have a degree of control over the partial.</p>
685
+
686
+ <p>In your <code>js_templates</code> folder, add the partial <code>_saved_properties.liquid</code>. In it we need a couple of constructs, the first is:</p>
687
+
688
+ <pre><code>{% raw %}
689
+ &lt;script id="saved_properties_template" type="text/liquid"&gt;
690
+ &lt;div class="content box"&gt;
691
+ &lt;h3&gt;My property shortlist&lt;/h3&gt;
692
+ &lt;div class="shortlist_inner"&gt;
693
+ &lt;div id="property_shortlist" class="content-block"&gt;
694
+ &lt;div id='favourite_property_list' class="content"&gt;&lt;/div&gt;
695
+ &lt;/div&gt;
696
+ &lt;/div&gt;
697
+ &lt;/div&gt;
698
+ &lt;/script&gt;
699
+ </code></pre>
700
+
701
+ <p>Essentially this is our widget container. Here's the next construct:</p>
702
+
703
+ <pre><code> &lt;script id="saved_property_template" type="text/liquid"&gt;
704
+ &lt;div id="mini_property_{{property.property_id}}" class="mini_property mini_property_{{property.property_id}}"&gt;
705
+ &lt;div style="position:relative;" class="clearfix"&gt;
706
+ &lt;img src="/liquid_assets/images/delete.png" style="display: none;" id="remove_icon_{{property.property_id}}"
707
+ class="remove_icon" onclick="javascript:Ctesius.Actions.removeSavedProperty({{property.property_id}})"&gt;
708
+ &lt;a href="{{property.property_url}}"&gt;&lt;img src="{{ property.small_photo }}" class="shortlist_img"&gt;&lt;/a&gt;
709
+ &lt;div class="featured_property_data"&gt;
710
+ &lt;a href="{{property.property_url}}"&gt;{{ property.bedrooms }} bedrooms&lt;/a&gt;&lt;br /&gt;
711
+ &lt;a href="{{property.property_url}}"&gt;{{ property.price }}&lt;/a&gt;&lt;br /&gt;
712
+ &lt;a href="{{property.property_url}}"&gt;{{ property.road_name | truncate : 20 }}&lt;/a&gt;
713
+ &lt;/div&gt;
714
+ &lt;/div&gt;
715
+ &lt;/div&gt;
716
+ &lt;/script&gt;
717
+ {% endraw %}
718
+ </code></pre>
719
+
720
+ <p>This construct is the actual saved property record within the widget.</p>
721
+
722
+ <p>There's quite a lot here to digest but most of it we have touched on previously in the Wiki. The <code>raw</code> tag however, is one we haven't seen so far. Anything within the raw tag is ignored by the Liquid serverside parser. Instead it's sent back to the browser for (in our case) the application JavaScript to process. As you can see we output the property's ID in various places so we can get a handle on it.</p>
723
+
724
+ <p>Next we need to allow our widget to show up somewhere in your theme - typically a sidebar. Add the following code whereever you would like it to show: </p>
725
+
726
+ <p><code>&lt;div id="saved_properties_view" class="hidden"&gt;&lt;/div&gt;</code>. </p>
727
+
728
+ <p>This will render the results of the script code seen above within the <code>saved_properties_view</code> div tags.</p>
729
+
730
+ <p>Next we need to output a save button or link on each property. To do that we add the following code to our <code>_property_small.liquid</code> that we worked with earlier in the Wiki (and the grid view if you have one):</p>
731
+
732
+ <pre><code>&lt;a class="shortlist_link_{{ property.property_id }}"
733
+ onclick="Ctesius.Actions.addSavedProperty({{property.property_id}}); return false;"&gt;
734
+ Add to Shortlist
735
+ &lt;/a&gt;
736
+ </code></pre>
737
+
738
+ <p>The new code here is the <code>Ctesius addSavedProperty action</code> - essentially this saves the JSON representation of property's information to the browser's local storage for retrieval as and when required. It is now close to working but there's some events we need to add to <code>js_event_registers</code> to stitch it all together. The first is in an event to do some stuff when the view is rendered (i.e. when the user clicks the add button):</p>
739
+
740
+ <pre><code>Ctesius.registerEvent('saved_property_view_rendered', function(saved_property){
741
+ $('#saved_properties_view').removeClass("hidden");
742
+ $(".shortlist_link_"+saved_property.id).html("Remove from Shortlist");
743
+ $(".shortlist_link_"+saved_property.id).attr("onclick", 'Ctesius.Actions.removeSavedProperty('+saved_property.id+'); return false;');
744
+ $('#mini_property_'+saved_property.id).mouseenter(function(){$('#remove_icon_'+saved_property.id).show()});
745
+ $('#mini_property_'+saved_property.id).mouseleave(function(){$('#remove_icon_'+saved_property.id).hide()});
746
+ });
747
+ </code></pre>
748
+
749
+ <p>Firstly we remove the hidden class from our sidebar widget so it shows. We then target the link, change the HTML to <code>Remove from Shortlist</code> then we add a click event to remove the very same property. Our last two lines are jQuery callback functions that show or hide the visual aid signifiying the user can remove the property.</p>
750
+
751
+ <h2>
752
+ <a name="saving-searches" class="anchor" href="#saving-searches"><span class="octicon octicon-link"></span></a>Saving searches</h2>
753
+
754
+ <p>Saving searches is a tad quicker and easier to set up than the saved properties and they save in much the same way as the saved properties. They also make use of the events system to give the user some feedback. Here's the first bit of code you will need to add where you would like the link/button:</p>
755
+
756
+ <pre><code>{% if location %}
757
+ &lt;li&gt;&lt;a onclick="Ctesius.Actions.saveCurrentSearch();" id="save_search"&gt;SAVE SEARCH&lt;/a&gt;&lt;/li&gt;
758
+ {% endif %}
759
+ </code></pre>
760
+
761
+ <p>Here you can see we have wrapped the link in a location if statement. You don't <em>have</em> to do this, though a saved search and the resultant email alerts to the user might not be very useful if the properties are not where they want to live or the location where they searched. Much like the saved properties function, here we call <code>saveCurrentSearch()</code>. We also give the link an ID so we can grab it in context using our events. </p>
762
+
763
+ <p>Speaking of events, here's the two we'll need to provide the user with some feedback:</p>
764
+
765
+ <pre><code>Ctesius.registerEvent('saved_search_added', function(search, collection){
766
+ if (search.equalTo(Ctesius.getSearch())){
767
+ $('#save_search').html('REMOVE SEARCH');
768
+ $("#save_search").attr("onClick", 'Ctesius.Actions.removeSavedSearch("'+search.search_id()+'");')
769
+ }
770
+
771
+ $('#saved_searches_link').effect('highlight',{color: '{{theme_preferences.accent_colour}}'}, 3000);
772
+ });
773
+
774
+ Ctesius.registerEvent('saved_search_removed', function(search, collection){
775
+ if (search.equalTo(Ctesius.getSearch())){
776
+ $("#save_search").html("SAVE SEARCH")
777
+ $("#save_search").attr("onclick", 'Ctesius.Actions.saveCurrentSearch();')
778
+ }
779
+ });
780
+ </code></pre>
781
+
782
+ <p>Again we're calling some Ctesius functions that will add or remove the saved search accordingly. We then set the display of the link and add the <code>onclick</code> events as needed. There's a couple of new statements used in this code that are worth a look:</p>
783
+
784
+ <p><code>$('#saved_searches_link').effect('highlight',{color: '{{theme_preferences.accent_colour}}'}, 3000);</code></p>
785
+
786
+ <p>The first is more a concept than anything else - the events that we can get a handle on are not only good for adding and removing properties, searches etc, but can also be used to provide visual aids to the user. Here the <code>saved_searches_link</code> in the user profile header (more on this later) is highlighted and then fades out to show the user that the search was saved and can be viewed/amended in their control panel.</p>
787
+
788
+ <p>The other new Liquid tag is <code>{{theme_preferences.accent_colour}}</code>.</p>
789
+
790
+ <p>Earlier we mentioned that LCSS files are run through a Liquid filter. If you're building a theme that will be rolled out to multiple agencies, or if you want to standardise the colour palette and manage it in one place, you can use the <code>agency/portal admin</code> to set the colours, then pull them out in Liquid using tags similar to the one above. </p>
791
+
792
+ <h1>
793
+ <a name="draw-a-map" class="anchor" href="#draw-a-map"><span class="octicon octicon-link"></span></a>Draw a Map</h1>
794
+
795
+ <p><em>Coming soon</em></p>
796
+
797
+ <h1>
798
+ <a name="the-property-show-page" class="anchor" href="#the-property-show-page"><span class="octicon octicon-link"></span></a>The property show page</h1>
799
+
800
+ <h2>
801
+ <a name="outputting-basic-information" class="anchor" href="#outputting-basic-information"><span class="octicon octicon-link"></span></a>Outputting basic information</h2>
802
+
803
+ <p>Many of the concepts we have used on the results partial, property small and elsewhere in the Wiki get used on the property show page as well. The goal of the show page is to show all of the property's photos, videos, its full description, floor plans, brochures, Energy Performance Certificates (EPC) and its location on a map (including a Street view), then channel all of this into a telephone or email lead to the agency.</p>
804
+
805
+ <p>Your first requirement is likely to be an output of the property's address, or at least part of it, and its price in a title:</p>
806
+
807
+ <pre><code>&lt;h1&gt;{{property.display_address}}&lt;/h1&gt;
808
+ &lt;h2&gt;{{property.price}}&lt;/h2&gt;
809
+ </code></pre>
810
+
811
+ <p>Next you will probably want to output the photos of the property. Many developers use jQuery type photo sliders for displaying and navigating through the photos. Thankfully, by using the photos loop, this is relatively easy to achieve:</p>
812
+
813
+ <pre><code>{% for photo in property.photos %}
814
+ &lt;img src="{{ photo | url_for_property_photo : "410x308"}}" height="308" width="410" /&gt;
815
+ {% endfor %}
816
+ </code></pre>
817
+
818
+ <p>And if you just wanted the property's main photo:</p>
819
+
820
+ <pre><code>&lt;img src="{{property.main_photo | url_for_property_photo : "410x308"}}" height="308" width="410" /&gt;
821
+ </code></pre>
822
+
823
+ <p>Next we might want to output the short description for the property:</p>
824
+
825
+ <pre><code>{{property.short_description | truncate: 900}}
826
+ </code></pre>
827
+
828
+ <p>Then, to get the property's status (Sold, Let, etc), we can use:</p>
829
+
830
+ <pre><code>&lt;h4&gt;{{property.status}}&lt;/h4&gt;
831
+ </code></pre>
832
+
833
+ <h2>
834
+ <a name="other-property-drops" class="anchor" href="#other-property-drops"><span class="octicon octicon-link"></span></a>Other property drops</h2>
835
+
836
+ <pre><code>{{property.available_on}}
837
+ </code></pre>
838
+
839
+ <p>If supplied, the date the property is available.</p>
840
+
841
+ <pre><code>{% for feature in property.features %}
842
+ {{ feature }}
843
+ {% endfor %}
844
+ </code></pre>
845
+
846
+ <p>A list of property features that can be outputted to bullet points.</p>
847
+
848
+ <p><code>{{property.description}}</code></p>
849
+
850
+ <p>The full description.</p>
851
+
852
+ <p><code>{{property.road_name}}</code></p>
853
+
854
+ <p>The property's road name.</p>
855
+
856
+ <p><code>{{ property.vox_number }}</code></p>
857
+
858
+ <p>Homeflow is able to generate recorded telephone numbers for properties. Doing a check on this drop can see whether one is available.</p>
859
+
860
+ <p><code>{{property.bedrooms}}</code></p>
861
+
862
+ <p>A numerical figure that sometimes comes in as zero or empty so needs to be checked.</p>
863
+
864
+ <p><code>{{property.bathrooms}}</code></p>
865
+
866
+ <p>As above.</p>
867
+
868
+ <p><code>{{property.reception_rooms}}</code></p>
869
+
870
+ <p>As per bedrooms.</p>
871
+
872
+ <p><code>{{property.property_ref}}</code></p>
873
+
874
+ <p>The agent's supplied property reference.</p>
875
+
876
+ <pre><code>{% for floorplan in property.floorplans %}
877
+ {% if forloop.first %}
878
+ &lt;a href="http://mr0.homeflow.co.uk/{{ floorplan.image }}" title="Floor plan"&gt;
879
+ {% if property.floorplans.size == 1 %}
880
+ View floor plan
881
+ {% else %}
882
+ View floor plans
883
+ {% endif %}
884
+ &lt;/a&gt;
885
+ {% else %}
886
+ &lt;a href="http://mr0.homeflow.co.uk/{{ floorplan.image }}" style="display:none;" title="Floor plan"&gt;&lt;/a&gt;
887
+ {% endif %}
888
+ {% endfor %}
889
+ </code></pre>
890
+
891
+ <p>The collection of floor plans. This loop could output the floor plans to a light box e.g Fancybox, Colorbox, etc.</p>
892
+
893
+ <pre><code>{% for brochure in property.brochures %}
894
+ &lt;li&gt;&lt;a href="{{ brochure | url_for_property_asset }}"&gt;Download brochure&lt;/a&gt;&lt;/li&gt;
895
+ {% endfor %}
896
+ </code></pre>
897
+
898
+ <p>This for loop would output all the brochures supplied.</p>
899
+
900
+ <pre><code>{% for epc_chart in property.epc_charts %}
901
+ {% if forloop.first %}
902
+ &lt;a href="{{ epc_chart | url_for_property_asset }}"&gt;
903
+ {% if property.epc_charts.size == 1 %}
904
+ View EPC chart
905
+ {% else %}
906
+ View EPC charts
907
+ {% endif %}
908
+ &lt;/a&gt;
909
+ {% else %}
910
+ &lt;a href="{{ epc_chart | url_for_property_asset }}" style="display:none"&gt;&lt;/a&gt;
911
+ {% endif %}
912
+ {% endfor %}
913
+ </code></pre>
914
+
915
+ <p>As per above and floor plans.</p>
916
+
917
+ <h2>
918
+ <a name="working-with-maps" class="anchor" href="#working-with-maps"><span class="octicon octicon-link"></span></a>Working with maps</h2>
919
+
920
+ <p>Many developers employ the tabbing system for property maps so the user can cycle through the different types: road, streetview and satellite. The first requirement is some events:</p>
921
+
922
+ <pre><code>&lt;script&gt;
923
+ Ctesius.addConfig('small_map_element', 'contact_map')
924
+ Ctesius.registerEvent('render_tab', function(tab_name){
925
+ switch(tab_name){
926
+ case 'streetview':
927
+ {% gmap_for property as streetview in streetview %}
928
+ break;
929
+ case 'satellite':
930
+ {% gmap_for property as satellite in satellite %}
931
+ break;
932
+ }
933
+ });
934
+ &lt;/script&gt;
935
+ </code></pre>
936
+
937
+ <p>The first line here adds our map to the <code>contact_map</code> ID or class (seen below). The <code>render_tab</code> event registers a callback function that renders the appropriate Google map depending on the tab clicked. We then have our anchors and togglable areas:</p>
938
+
939
+ <pre><code>&lt;a class="selected" id="tab_map" href="#tabs/map"&gt;MAP&lt;/a&gt;
940
+ &lt;a id="tab_streetview" href="#tabs/streetview"&gt;STREETVIEW&lt;/a&gt;
941
+ &lt;a id="tab_satellite" href="#tabs/satellite"&gt;SATELLITE&lt;/a&gt;
942
+ </code></pre>
943
+
944
+ <pre><code>&lt;div id="togglable_map" class="togglable_area"&gt;
945
+ &lt;div id="contact_map"&gt;&lt;/div&gt;
946
+ &lt;/div&gt;
947
+ &lt;div id="togglable_streetview" class="togglable_area hidden"&gt;
948
+ &lt;div id='streetview' class="google_map_container"&gt;&lt;/div&gt;
949
+ &lt;/div&gt;
950
+ &lt;div id="togglable_satellite" class="togglable_area hidden"&gt;
951
+ &lt;div id='satellite' class="google_map_container"&gt;&lt;/div&gt;
952
+ &lt;/div&gt;
953
+ </code></pre>
954
+
955
+ <h2>
956
+ <a name="submitting-a-lead" class="anchor" href="#submitting-a-lead"><span class="octicon octicon-link"></span></a>Submitting a lead</h2>
957
+
958
+ <p>Email type leads are submitted to Homeflow and then on to the agent by ubiquitous web forms. Here's a simplified version:</p>
959
+
960
+ <pre><code> &lt;form action="/properties/{{property.property_id}}/{{property.primary_channel}}/leads" method="post"&gt;
961
+ &lt;div id='form_error'&gt;&lt;/div&gt;
962
+ &lt;label class="text" for="firstname"&gt;First name&lt;/label&gt;
963
+ &lt;input id="firstname" name="lead_client[first_name]" type="text"&gt;
964
+ &lt;label class="text" for="surname"&gt;Last name&lt;/label&gt;
965
+ &lt;input id="surname" name="lead_client[last_name]" type="text"&gt;
966
+ &lt;label class="text" for="email"&gt;Email&lt;/label&gt;
967
+ &lt;input id="email" name="lead_client[email]" type="email"&gt;
968
+ &lt;label class="text" for="telephone"&gt;Telephone&lt;/label&gt;
969
+ &lt;input id="telephone" name="lead_client[tel_home]" type="text"&gt;
970
+ &lt;label class="text" for="message"&gt;Message&lt;/label&gt;
971
+ &lt;textarea id="message" name="lead[message]" rows="3"&gt;&lt;/textarea&gt;
972
+ &lt;button type="submit"&gt;Send enquiry&lt;/button&gt;
973
+ &lt;/form&gt;
974
+ </code></pre>
975
+
976
+ <p>If you are familiar with forms, which we're sure you are, there will be nothing new here to you. The only requirements are the names of the fields as well as the form action. The form error div near the top is reserved for any lead sending errors. Once a lead is sent, a <code>flash message</code> can be displayed. We have a whole array of flash notices that are used depending on the response back from the server and to display the notices, all you need to do is and the alert location div to your <code>application.liquid</code> or on the subject page itself:</p>
977
+
978
+ <pre><code>&lt;div id='alert_location'&gt;&lt;/div&gt;
979
+ </code></pre>
980
+
981
+ <h1>
982
+ <a name="working-with-agencies" class="anchor" href="#working-with-agencies"><span class="octicon octicon-link"></span></a>Working with agencies</h1>
983
+
984
+ <p>More commonly found on portals, the agency page acts as the top level holdall for the agency's branches, staff, contact details and so on. The Ctesius app comes with a URL pattern that can describe the agency, the branch and the staff, should you need it to. Let's look at what a typical agency page might contain.</p>
985
+
986
+ <h2>
987
+ <a name="the-agency-show-page" class="anchor" href="#the-agency-show-page"><span class="octicon octicon-link"></span></a>The agency show page</h2>
988
+
989
+ <p>Anything agency related will reside in the <code>agencies</code> folder in your Rails directory structure and your show page will follow the normal format of <code>show.liquid</code>. Let's start to build the page using the agency name, agency description and the agency's portal logo with a fallback to their default logo:</p>
990
+
991
+ <pre><code>&lt;h1&gt;{{agency.name}}&lt;/h1&gt;
992
+ </code></pre>
993
+
994
+ <pre><code>{% if agency.portal_logo %}
995
+ &lt;img src="{{agency.portal_logo | url_for_agency_logo : "200x_"}}" /&gt;
996
+ {% elsif agency.logo %}
997
+ &lt;img src="{{agency.logo | url_for_agency_logo : "200x_"}}" /&gt;
998
+ {% endif %}
999
+ </code></pre>
1000
+
1001
+ <pre><code>{{agency.description}}
1002
+ </code></pre>
1003
+
1004
+ <p>Next, let's add a Google style map to our show page - note that this will show the branches belonging to an agency:</p>
1005
+
1006
+ <pre><code>&lt;div id='agency_map'&gt;&lt;/div&gt;
1007
+ </code></pre>
1008
+
1009
+ <pre><code>&lt;script&gt;
1010
+ {% gmap_for agency.branches as roadmap in agency_map %}
1011
+ &lt;/script&gt;
1012
+ </code></pre>
1013
+
1014
+ <p>Don't forget to give your map div a height and a width setting in your CSS. </p>
1015
+
1016
+ <p>If you would prefer to use a Leaflet style map:</p>
1017
+
1018
+ <pre><code>&lt;div id='branches_map'&gt;&lt;/div&gt;
1019
+ </code></pre>
1020
+
1021
+ <pre><code>&lt;script type="text/javascript"&gt;
1022
+ Ctesius.addConfig('branch_map_element', 'branches_map');
1023
+ Ctesius.addConfig('branches', {% include_as_json branches/branches_list %});
1024
+ &lt;/script&gt;
1025
+ </code></pre>
1026
+
1027
+ <p>Now let's extract the branches of an agency, including their branch pic or logo, description etc:</p>
1028
+
1029
+ <pre><code>{% for branch in agency.branches_ordered_alphanumerically %}
1030
+ {% include "branches/branch_small" %}
1031
+ {% endfor %}
1032
+ </code></pre>
1033
+
1034
+ <p>Note that we're ordering the branches alphabetically using a helper function and we're reusing our <code>branch_small</code>. Not only is this excellent reuse, but it means if your branch_small layout is sorted, it should work out of the box on you agencies pages. In addition, when you need to make a change to it, it will be reflected on all pages that use it.</p>
1035
+
1036
+ <p>Finally, let's see how we can extract some social media links from the CRM:</p>
1037
+
1038
+ <pre><code>{% if agency.has_social_links %}
1039
+ &lt;div class="agency_social"&gt;
1040
+ {% if agency.facebook_uri %}
1041
+ &lt;a href="{{agency.facebook_uri }}" target="_blank"&gt;&lt;img src="{{'facebook' | theme_image_url}}" width="32" height="32"&gt;&lt;/a&gt;
1042
+ {% endif %}
1043
+ {% if agency.twitter_uri %}
1044
+ &lt;a href="{{agency.twitter_uri }}" target="_blank"&gt;&lt;img src="{{'twitter' | theme_image_url}}" width="32" height="32"&gt;&lt;/a&gt;
1045
+ {% endif %}
1046
+ {% if agency.linkedin_uri %}
1047
+ &lt;a href="{{agency.linkedin_uri }}" target="_blank"&gt;&lt;img src="{{'linkedin' | theme_image_url}}" width="32" height="32"&gt;&lt;/a&gt;
1048
+ {% endif %}
1049
+ {% if agency.googleplus_uri %}
1050
+ &lt;a href="{{agency.googleplus_uri }}" target="_blank"&gt;&lt;img src="{{'google-plus' | theme_image_url}}" width="32" height="32"&gt;&lt;/a&gt;
1051
+ {% endif %}
1052
+ &lt;/div&gt;
1053
+ {% endif %}
1054
+ </code></pre>
1055
+
1056
+ <p>This block of code first executes a <code>has_social_links</code> function - this checks whether any one of the standard social media slots has a value. If at least one does, it will execute the block. We then use individual agency drop checks to see if the URI is available and output a theme image linking to the URI if so.</p>
1057
+
1058
+ <h1>
1059
+ <a name="working-with-branches" class="anchor" href="#working-with-branches"><span class="octicon octicon-link"></span></a>Working with branches</h1>
1060
+
1061
+ <p>Way back at beginning of the Wiki we outlined the Rails folder structure we must use in order to retrieve property, agency, branch information and so on. To retrieve everything related to a branch, to perform branch searches and generally build the template up, we need to work in our <code>branches</code> folder. Let's start with the index file.</p>
1062
+
1063
+ <h2>
1064
+ <a name="the-branches-index" class="anchor" href="#the-branches-index"><span class="octicon octicon-link"></span></a>The branches index</h2>
1065
+
1066
+ <p>As we saw with the <code>properties index</code>, our index pages are called when no seach criteria is given and we just want a flat list of all properties, branches, etc. A branches index route would simply be: <code>http://www.agency_domain.com/branches</code>. On our index page we can add the following code:</p>
1067
+
1068
+ <pre><code>{% if branches != empty %}
1069
+ {% for branch in branches %}
1070
+ {% include "branches/branch_small" %}
1071
+ {% endfor %}
1072
+ {% endif %}
1073
+ </code></pre>
1074
+
1075
+ <p>This construct is exactly the same as a properties loop seen before except we are referencing our branches collection as well as including a <code>branch_small</code> partial for each returned branch. A <code>branch_small</code> might look something like:</p>
1076
+
1077
+ <pre><code>&lt;div class="branch"&gt;
1078
+ {% if branch.agency.portal_logo %}
1079
+ &lt;img src="{{ branch.agency.portal_logo | url_for_agency_logo : "150!" }}" /&gt;
1080
+ {% else %}
1081
+ &lt;img src="{{ 'awaiting-image.png' | theme_image_url }}" /&gt;
1082
+ {% endif %}
1083
+ &lt;div class="details"&gt;
1084
+ &lt;h3&gt;
1085
+ &lt;a href="{{ branch | url_for_branch}}"&gt;{{branch.name}} branch&lt;/a&gt;
1086
+ &lt;/h3&gt;
1087
+ &lt;p class="content"&gt;
1088
+ {{branch.description | strip_tags | truncate : 250}}
1089
+ &lt;/p&gt;
1090
+ &lt;p&gt;
1091
+ &lt;a href="{{ branch | url_for_branch}}"&gt;More Information&lt;/a&gt;
1092
+ &lt;/p&gt;
1093
+ &lt;/div&gt;
1094
+ &lt;/div&gt;
1095
+ </code></pre>
1096
+
1097
+ <p>Here we are checking whether the agency's portal logo has been set and if it has, we output it in the source. Note you could use <code>{{ branch.photo | url_for_generic_image: "150!" }}</code> instead, which would retrieve the branch photo as set in the branches area of the agency or portal admin. This photo is normally a shop front image or something similar. As another alternative, you could use the overall agency logo: <code>{{ agency.logo | url_for_agency_logo : '150!'}}</code>. Note that we've got a backup coded in to output a standard holding image if no portal logo is available. This is a <code>theme_image_url</code> - you may remember theme images reside in <code>/assets/images</code>.</p>
1098
+
1099
+ <p>One new element here is the bang (explanation mark) after the width dimension. We've built in some nifty Liquid filters that give you some flexiblity when requesting images from the server. In this instance we're saying: get us the agency portal logo and resize it so the width and height are no more than 150 pixels. Other options here are to specify the dimensions exactly or specify a height or a width, then get Liquid to automatically set the other dimension whilst retaining the aspect ratio - we do this by using an underscore where the dimension you want to calculate would normally be, e.g: "150x_".</p>
1100
+
1101
+ <p>Next we're outputting the branch name and wrapping it in the URL for the branch. We then go on to output the branch description. Note that in some instances you might be able to guarantee that the description has been added, if you can't then you can wrap the output in an <code>{% if branch.description %}</code>. Note the truncate filter that we've seen before. There's also a new filter here called <code>strip_tags</code>. Along with <code>strip_html</code> and <code>strip_links</code> it strips the description of any unwanted HTML tags and links.</p>
1102
+
1103
+ <p>Not every theme will call for a <code>branch_small</code> partial to be used - some might just have the name of the branch and a link, whilst others might have the name, link and a map of the branches.</p>
1104
+
1105
+ <h2>
1106
+ <a name="working-with-branch-maps" class="anchor" href="#working-with-branch-maps"><span class="octicon octicon-link"></span></a>Working with branch maps</h2>
1107
+
1108
+ <p>Homeflow supports a variety of map types which you can extend with custom pins, overlays and so on. The first and easiest map to set-up is the Leafleft.js map type. To get this up and running on the branches index page, start by adding:</p>
1109
+
1110
+ <pre><code>&lt;script&gt;
1111
+ Ctesius.addConfig('branch_map_element', 'branch_map');
1112
+ Ctesius.addConfig('branches', {% include_as_json branches/branches_list %});
1113
+ &lt;/script&gt;
1114
+ </code></pre>
1115
+
1116
+ <p>This is the first time we've seen a built-in Ctesius <code>addConfig</code> function - the first <code>addConfig</code> assigns our branch map to the element <code>branch_map</code> whilst the second outputs a dump of JSON branch information for use on the front end. Next we need to declare our <code>div</code> to apply the map to:</p>
1117
+
1118
+ <p><code>&lt;div id="branch_map"&gt;&lt;/div&gt;</code></p>
1119
+
1120
+ <p>Don't forget to give your map ID or class and height and/or width to get it to show up. This should be enough to get your Leaflet branch map showing with a pin for each branch. The map bubbles have a fairly basic presentation that's fine for most, but if you would like to customise your pin, you can override <code>_branch_map_pin.liquid</code> in your <code>js_templates</code> folder and customise the layout and styles as necessary. Note that you'll need the basic layout code in the override, if you don't have this, pop us a line or grab it from another theme if we've given you access.</p>
1121
+
1122
+ <p>If you would prefer a Google style map you still need the <code>addConfig branches</code> code seen before, but this time, instead of your <code>addConfig branch_map</code>, we need:</p>
1123
+
1124
+ <p><code>{% gmap_for agency.branches as roadmap in branch_map %}</code></p>
1125
+
1126
+ <p>This should then populate your <code>branch_map</code> div with a Google style map. Note that we're using the <code>agency.branches</code> <code>drop</code> to access the branches belonging to an agency.</p>
1127
+
1128
+ <h2>
1129
+ <a name="branch-searching" class="anchor" href="#branch-searching"><span class="octicon octicon-link"></span></a>Branch searching</h2>
1130
+
1131
+ <p>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:</p>
1132
+
1133
+ <pre><code>&lt;form action="/branches" id="search" method="get"&gt;
1134
+ &lt;input type="text" name="location" id="location" class="autocomplete_location"&gt;
1135
+ &lt;input type='hidden' name='place_id' value='{{place_id}}' class='autocomplete_location_result' /&gt;
1136
+ &lt;button value="Search" type="submit"&gt;&lt;/button&gt;
1137
+ &lt;/form&gt;
1138
+ </code></pre>
1139
+
1140
+ <p>Next where you branch results need to be, we have:</p>
1141
+
1142
+ <pre><code>{% if branches != empty %}
1143
+ {% for branch in branches %}
1144
+ {% include 'branches/branch_small' %}
1145
+ {% endfor %}
1146
+ {% else %}
1147
+ &lt;h1&gt;Sorry, no branches were found.&lt;/h1&gt;
1148
+ {% endif %}
1149
+ </code></pre>
1150
+
1151
+ <p>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.</p>
1152
+
1153
+ <h2>
1154
+ <a name="branch-titles-and-pagination" class="anchor" href="#branch-titles-and-pagination"><span class="octicon octicon-link"></span></a>Branch titles and pagination</h2>
1155
+
1156
+ <p>Much like we saw earlier in teh Wiki 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:</p>
1157
+
1158
+ <pre><code>{% if location %}
1159
+ {% if location.name != ''%}Branches in {{ location.name }}{% if county %}, {{county.name}}{% endif %}{% endif %}
1160
+ {% elsif county %}
1161
+ Branches in {{ county.name }}
1162
+ {% elsif postcode %}
1163
+ Branches in {{ postcode.postcode }}
1164
+ {% else %}
1165
+ Branches Index
1166
+ {% endif %}
1167
+ </code></pre>
1168
+
1169
+ <p>As you can see, the IF statement checks for the location or location type and outputs the appropriate heading between a heading tag. Remember that if you use the construct multiple times, you can add it to a partial if you wish.</p>
1170
+
1171
+ <p>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:</p>
1172
+
1173
+ <pre><code>Page {{pagination.current_page}} of
1174
+ {% if pagination.has_next_page %}
1175
+ {{pagination.total_count}}
1176
+ {% else %}
1177
+ {{pagination.current_page}}
1178
+ {% endif %}&lt;br&gt;
1179
+ {% if pagination.has_prev_page %}
1180
+ &lt;a href="{{pagination.previous_page_link}}"&gt;&amp;laquo; Previous page&lt;/a&gt;
1181
+ {% endif %}
1182
+ {% if pagination.has_prev_page and pagination.has_next_page %}
1183
+ -
1184
+ {% endif %}
1185
+ {% if pagination.has_next_page %}
1186
+ &lt;a href="{{pagination.next_page_link}}"&gt;Next page &amp;raquo;&lt;/a&gt;
1187
+ {% endif %}
1188
+ </code></pre>
1189
+
1190
+ <p>This might output something like:</p>
1191
+
1192
+ <pre><code> Page 2 of 178
1193
+ « Previous page - Next page »
1194
+ </code></pre>
1195
+
1196
+ <p>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.</p>
1197
+
1198
+ <h2>
1199
+ <a name="the-branch-show" class="anchor" href="#the-branch-show"><span class="octicon octicon-link"></span></a>The branch show</h2>
1200
+
1201
+ <p>Wherever we have a Liquid tag that looks like <code>{{ branch | url_for_branch}}</code> 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 <code>show.liquid</code> and lives in the branches folder.</p>
1202
+
1203
+ <p>The branch show page supports many of the things we saw on the property show page - for instance, you could have a JavaScript based carousel showing branch photos, list the staff members belonging to a branch, output the branch description and so on. What information you fetch and how you display it will of course depend on your design, but let's run through the basics:</p>
1204
+
1205
+ <p>To get the branch name we use the branch drop and name: <code>{{branch.name}}</code>. Moving on, we can then fetch the branch description:</p>
1206
+
1207
+ <pre><code>{% if branch.description_with_agency_fallback %}
1208
+ &lt;p&gt;
1209
+ {{branch.description_with_agency_fallback | strip_html}}
1210
+ &lt;/p&gt;
1211
+ {% endif %}
1212
+ </code></pre>
1213
+
1214
+ <p>This nifty bit of code will try and get the branch description, but if it's empty, we'll get the agency description. Note that it is unlikely an agent will not have a description for their branch AND their agency, but it's always good practice to check. Notice also we're stripping the HTML as sometimes some links and other formatting gets added to the description which can wreak havoc on our layout.</p>
1215
+
1216
+ <p>Staff profiles are a whole subject unto themselves which we will look at later in the Wiki but for now, if you wanted to display some mini profiles with links to full profiles, or just give you branch pages the human touch, you could use something like:</p>
1217
+
1218
+ <pre><code>{% unless branch.staff_profiles.size == 0 %}
1219
+ &lt;div class="sm_staff_gallery"&gt;
1220
+ {% for staff_member in branch.staff_profiles limit:6 %}
1221
+ {% if staff_member.avatar %}
1222
+ &lt;a href="{{ staff_member | url_for_staff_member}}" title="{{staff_member.name}}"&gt;
1223
+ &lt;img src="{{ staff_member.avatar | url_for_staff_profile_avatar : "40x40" }}" title="{{staff_member.name}}"&gt;
1224
+ &lt;/a&gt;
1225
+ {% else %}
1226
+ &lt;a href="{{ staff_member | url_for_staff_member}}" title="{{staff_member.name}}"&gt;
1227
+ &lt;img src="/liquid_assets/images/sp.jpg" height="40" width="40" title="{{staff_member.name}}"&gt;
1228
+ &lt;/a&gt;
1229
+ {% endif %}
1230
+ {% endfor %}
1231
+ &lt;/div&gt;
1232
+ {% endunless %}
1233
+ </code></pre>
1234
+
1235
+ <p>Everything here should be reasonably familiar to you, though note we've added a <code>limit</code> to our for loop so that a maximum of six profiles are extracted. Also note that we're referencing a fallback image directly. Whilst this is a quirk of this code copied from a theme, sometimes you might need to reference an image using its relative path. On the whole though, you can just use Liquid and <code>theme_image_url</code>.</p>
1236
+
1237
+ <h2>
1238
+ <a name="displaying-branch-properties" class="anchor" href="#displaying-branch-properties"><span class="octicon octicon-link"></span></a>Displaying branch properties</h2>
1239
+
1240
+ <p>The branch properties page is one where we can thankfully reuse our property loops and pagination figures as seen on the property results. Alternatively we can make use of the tabbing facility and include a function that will return some recent sales or recent lettings. If you would like to get the full results and make use of pagination, we'll need to use the former of the two options as the properties method in the branches controller needs to run to return the results and pagination.</p>
1241
+
1242
+ <p>Typically branch pages will make use of our built-in tabbing facility as seen earlier for property results. To get the tabs up and running, you will need the following code:</p>
1243
+
1244
+ <pre><code>&lt;ul class="nav-menu nav-tabs"&gt;
1245
+ &lt;li&gt;&lt;a href="#tabs/summary" id="tab_summary" class="selected"&gt;Summary&lt;/a&gt;&lt;/li&gt;
1246
+ &lt;li&gt;&lt;a href="#tabs/team" id="tab_team"&gt;Meet our team&lt;/a&gt;&lt;/li&gt;
1247
+ &lt;li&gt;&lt;a href="#tabs/sales" id="tab_sales"&gt;Our sales&lt;/a&gt;&lt;/li&gt;
1248
+ &lt;li&gt;&lt;a href="#tabs/lettings" id="tab_lettings"&gt;Our lettings&lt;/a&gt;&lt;/li&gt;
1249
+ &lt;/ul&gt;
1250
+ </code></pre>
1251
+
1252
+ <p>NB: the Ctesius app will take care of adding <code>selected active</code> classes to your tabs but you will need to style them.</p>
1253
+
1254
+ <h3>
1255
+ <a name="recent-sales-and-lettings" class="anchor" href="#recent-sales-and-lettings"><span class="octicon octicon-link"></span></a>Recent sales and lettings</h3>
1256
+
1257
+ <p>Now we have our tabs, we can add the area that will be toggled on a click. Here's what a togglable sales tab and recent branch sales function looks like:</p>
1258
+
1259
+ <pre><code>{% if branch.recent_sales_properties != empty %}
1260
+ &lt;script&gt;
1261
+ {% assign properties = branch.recent_sales_properties %}
1262
+ sales_property_for_config = {% include_as_json properties/properties_list %}.properties
1263
+ &lt;/script&gt;
1264
+ &lt;div id="togglable_sales" class="togglable_area clearfix hidden"&gt;
1265
+ &lt;h2&gt;Latest sale listings for {{branch.name}}&lt;/h2&gt;
1266
+ {% for property in branch.recent_sales_properties limit: 20 %}
1267
+ {% include "properties/property_small" %}
1268
+ {% endfor %}
1269
+ &lt;/div&gt;
1270
+ {% endif %}
1271
+ </code></pre>
1272
+
1273
+ <p>Here we're making us of one of Ctesius's many built-in functions - this one gets recent properties that the branch has added or we have received via a feed. To get this up and running we literally call the function which returns the JSON we need. We then use the good ol' properties loop to output the results, whilst reusing our <code>property_small</code>. Note that we've wrapped this whole block in an IF statement that checks if the function returns empty. It would be good practice to hide the link to the tab if the function has no results too.</p>
1274
+
1275
+ <p>To get this up and running for lettings, just substitute any reference to sales for lettings.</p>
1276
+
1277
+ <h3>
1278
+ <a name="all-branch-properties" class="anchor" href="#all-branch-properties"><span class="octicon octicon-link"></span></a>All branch properties</h3>
1279
+
1280
+ <p>If you would like to display all properties that belong to a branch with pagination, we'll need a <code>properties.liquid</code> file within the branches folder. Once you have this you can start to build up the layout. This will most likely be a hybrid of your properties result page and your branch show page so use partials where possible and reuse what you've already written. </p>
1281
+
1282
+ <p>To start with, you might want to add a title:</p>
1283
+
1284
+ <pre><code>&lt;h1&gt;{{agency.name}} - {{branch.name}} branch - All {{current_channel}}&lt;/h1&gt;
1285
+ </code></pre>
1286
+
1287
+ <p>Not much new here but it's worth knowing that <code>{{current_channel}}</code> will return either a 'Sales' or 'Lettings' string. Next you might want some tabs that will enable the user to navigate around:</p>
1288
+
1289
+ <pre><code>&lt;ul class="nav-menu nav-tabs"&gt;
1290
+ &lt;li&gt;&lt;a href="{{branch | url_for_branch : branch.agency}}#tabs/summary" id="tab_summary"&gt;Summary&lt;/a&gt;&lt;/li&gt;
1291
+ &lt;li&gt;&lt;a href="#tabs/team" id="tab_team"&gt;Meet our team&lt;/a&gt;&lt;/li&gt;
1292
+ {% if branch.sales_branch_properties_count &gt; 0 %}
1293
+ &lt;li&gt;&lt;a href="{{branch | url_for_branch : branch.agency}}/sales" id="sales"&gt;Our sales&lt;/a&gt;&lt;/li&gt;
1294
+ {% endif %}
1295
+ {% if branch.lettings_branch_properties_count &gt; 0 %}
1296
+ &lt;li&gt;&lt;a href="{{branch | url_for_branch : branch.agency}}/lettings" id="lets"&gt;Our lettings&lt;/a&gt;&lt;/li&gt;
1297
+ {% endif %}
1298
+ &lt;/ul&gt;
1299
+ </code></pre>
1300
+
1301
+ <p>The first two tabs here would be hidden tabs on the page that get selected and displayed on a click. The branch properties tabs however, need to go through the branch properties controller to get the results. All we need do here is specify the appropriate branch URL with <code>/sales</code> or <code>/lettings</code>. If you're developing a portal with agencies that have multiple branches, you will need to use <code>{{branch | url_for_branch : branch.agency}}</code> in your URL, else you can just use <code>{{branch | url_for_branch}}</code>.</p>
1302
+
1303
+ <p>Next we need to output the actual results that are returned from our request. Thankfully this is just the same as outputting our property results seen earlier so you will have your pagination header, property loop, property small output and footer pagination (if required).</p>
1304
+ </section>
1305
+
1306
+ <aside id="sidebar">
1307
+
1308
+ <ul>
1309
+ <li><a href="/homeflow/homeflow_api/wiki">Home</a></li>
1310
+ <li>
1311
+ <a href="/homeflow/homeflow_api/wiki/ctesius#getting-started">Getting started</a>
1312
+
1313
+ <ul>
1314
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#theme-folder-structure">Theme folder structure</a></li>
1315
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#the-layout-file">The layout file</a></li>
1316
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#building-up-the-layout">Building up the layout</a></li>
1317
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#running-your-theme">Running your theme</a></li>
1318
+ </ul>
1319
+ </li>
1320
+ <li>
1321
+ <a href="/homeflow/homeflow_api/wiki/ctesius#building-up-the-application-and-home-page">Application &amp; home page</a>
1322
+
1323
+ <ul>
1324
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#the-header-with-an-agency-or-portal-logo">The header</a></li>
1325
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#the-navigation-menu">The navigation menu</a></li>
1326
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#the-carousel">The carousel</a></li>
1327
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#the-footer">The footer</a></li>
1328
+ </ul>
1329
+ </li>
1330
+ <li>
1331
+ <a href="/homeflow/homeflow_api/wiki/ctesius#working-with-property-searches">Property Searching</a>
1332
+
1333
+ <ul>
1334
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius/working-with-property-searches#constructing-a-property-search-form">Property search form</a></li>
1335
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#displaying-search-results">Displaying search results</a></li>
1336
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#the-properties-loop">The properties loop</a></li>
1337
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#handling-with-locations-and-postcodes">Locations and postcodes</a></li>
1338
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#headings-and-pagination">Headings and pagination</a></li>
1339
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#more-on-pagination">More on pagination</a></li>
1340
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#togglable-areas">Togglable areas</a></li>
1341
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#working-with-the-map-view">Working with map views</a></li>
1342
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#working-with-grid-views">Working with grid views</a></li>
1343
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#saving-properties-to-a-shortlist">Saving to shortlist</a></li>
1344
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#saving-searches">Saving searches</a></li>
1345
+ </ul>
1346
+ </li>
1347
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#draw-a-map">Draw a Map</a></li>
1348
+ <li>
1349
+ <a href="/homeflow/homeflow_api/wiki/ctesius#the-property-show-page">The property show page</a>
1350
+
1351
+ <ul>
1352
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#outputting-basic-information">Outputting basic information</a></li>
1353
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#other-property-drops">Other property drops</a></li>
1354
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#working-with-maps">Working with maps</a></li>
1355
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#submitting-a-lead">Submitting a lead</a></li>
1356
+ </ul>
1357
+ </li>
1358
+ <li>
1359
+ <a href="/homeflow/homeflow_api/wiki/ctesius#working-with-agencies">Working with agencies</a>
1360
+
1361
+ <ul>
1362
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#the-agency-show-page">Agency show page</a></li>
1363
+ </ul>
1364
+ </li>
1365
+ <li>
1366
+ <a href="/homeflow/homeflow_api/wiki/ctesius#working-with-branches">Working with branches</a>
1367
+
1368
+ <ul>
1369
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#the-branches-index">The branches index</a></li>
1370
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#working-with-branch-maps">Branch maps</a></li>
1371
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#branch-searching">Branch searching</a></li>
1372
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#branch-titles-and-pagination">Titles and pagination</a></li>
1373
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#the-branch-show">The branch show</a></li>
1374
+ <li>
1375
+ <a href="/homeflow/homeflow_api/wiki/ctesius#displaying-branch-properties">Branch properties</a>
1376
+
1377
+ <ul>
1378
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#displaying-branch-properties">Recent sales and lettings</a></li>
1379
+ <li><a href="/homeflow/homeflow_api/wiki/ctesius#all-branch-properties">All branch properties</a></li>
1380
+ </ul>
1381
+ </li>
1382
+ </ul>
1383
+ </li>
1384
+ </ul>
1385
+
1386
+
1387
+ <!--<a href="https://github.com/homeflow/homeflow_api/zipball/master" class="button">
1388
+ <small>Download</small>
1389
+ .zip file
1390
+ </a>
1391
+ <a href="https://github.com/homeflow/homeflow_api/tarball/master" class="button">
1392
+ <small>Download</small>
1393
+ .tar.gz file
1394
+ </a>-->
1395
+
1396
+ <p class="repo-owner"><a href="https://github.com/homeflow/homeflow_api"></a> is maintained by <a href="https://github.com/homeflow">homeflow</a>.</p>
1397
+
1398
+ <p>This page was generated by <a href="https://pages.github.com">GitHub Pages</a> using the Architect theme by <a href="https://twitter.com/jasonlong">Jason Long</a>.</p>
1399
+ </aside>
1400
+ </div>
1401
+ </div>
1402
+
1403
+
1404
+ </body>
1405
+ </html>