Code By Example

Overview

Code examples of functionality that can be created in FarCry. We're focused on sample code here so in many instances there is little explanation beyond the code comments.

Code Samples
  • Autocomplete FormtoolA formtool that provides autocomplete functionality.
  • Colour FormtoolA formtool for editing a colour property
  • Content Review Reporta script that looks at content which is due for review in the last 24 hours and sends an e-mail to the content owner requesting their attention
  • Custom Overview Tab - Related ContentFarCry makes it easy to add tabs to an object's overview. This example shows how to use this to add a tab that shows all content in the system that is related to the selected object
  • Error TrappingChange the default error trapping.
  • Extending Profile with Departmentsadd a departments type for dmprofile, now you can enter a department name, why not create a department type that is included as default in the core
  • Form tool buttonsForm tools buttons have many options such as render type and validate.
  • Google SitemapSitemaps facility in farcry lets you dynamically create a google sitemap with just a few lines of code.
  • Login Pages
  • Script to resize imagesThis code loops through all dmImages and resizes them according to dmImage form tools properties. This is great if there is an existing image library but the requirements have changed. Instead of going through every image and re-saving, just run this script.
  • Slider FormtoolThe formtool is an extension of the numeric formtool found in core, so you can use any of the features found from that formtool in the slider (ftPrefix, ftSuffix, etc).
FarCry 5.x.x Code Examples

Code examples from older FarCry versions; should still work just fine, but be mindful that there may be more modern techniques available.

  • Basic search form for dmNewsThis is a basic search form which enables you to place a search option for dmNews, you can build it further as required.
  • CAS + LDAP Unique ExampleHere is a small example for creating your own User Directory that might be interfacing with some unique situations. Here there is a combined CAS for login + LDAP for group identification.
  • Flush ColdFusion trusted cache from Farcry WebtopYou can improve (production) performance by turning on trusted cache for your ColdFusion server. However, it's easy to forget that trusted cache is on when you do an update. Here is how to add this functionality to the FarCry Webtop so you can flush cache when you re-initialise the application.
  • ftWatch ExampleHere is a quick primer on how to use ftWatch in a formtool. Basically, two things get passed into the functions of a formtool (such as edit() or display())
  • Link Array FormtoolEver wanted to allow users to capture a bunch of links in a property that you can output? You could always use the FarCry CMS Link content type, but its a bit unwieldy, especially if your links are really only related to one specific content item and don't make sense in a library. Well you are in luck
  • Sample iTunes FeedBuilding an iTunes feed is relatively straightforward in ColdFusion. The trick in FarCry Framework is knowing where to put the code. This example is taken directly from the webDU Developer Conference website.
  • Sample RSS FeedBuilding an RSS feed is very straightforward in ColdFusion. The trick in FarCry Framework is knowing where to put the code. This example is taken directly from the Fullasagoog website.
  • Simple pollingThis rule provides a very simple widget that can be added to any container, presenting users with a question and list of options then displaying the results after they choose.
FarCry 4.x.x Code Examples

Code examples from older FarCry versions; should still work just fine, but be mindful that there may be more modern techniques available.

  • Image Gallery RuleTry this very simple image gallery rule. Grey box is basically a pop up window that doesn't suck. Just install the existing FarCry Greybox plugin and you are all set. Select the images you want from the image library and display them using Grey Box.
  • Sample Promotional TileWe needed a simple promotional tile for placing on the website. This was used to promote other areas on the site or external subsites of the clients. The tile can have either a fixed horizontal image or a vertical image. The individual tiles will be placed onto the site using the "hand-picked" publishing rule.
  • Showing Related ContentOne of FarCry's real strengths is the ability to easily create and display cross related content. All you need is a content type that records the references using an array or library property (for example, dmHTML the content type for standard HTML pages) and some presentation logic in your view.