UNIT XX - Containers & Publishing Rules

Work in Progress

Updating the course for FarCry 6.x. If you can help let us know! Put your notes in the comments for the page.

Section will include:

  • creating containers; single instances, and reflected containers
  • creating publishing rules
    • something with an internal content type eg. super hero theme
    • something external, perhaps twitter or other feed process
  • discussion various container variations; including restricted rule lists, managing access to container management

Objectives

Adding containers to templates and creating publishing rules to populate them.

Quick post from Sean to help in the interim

So, the gist of rules are that they are a content type, just like custom content types you would write. Instead of extending farcry.core.packages.types.types, you would write a CFC that extends farcry.core.packages.rules.rules, place this CFC in your /farcry/projects/yourProject/packages/rules directory. In this CFC, you would add your cfproperty tags, just as you would for a custom content type. If you haven't created a custom content type yet, I would suggest you read through those units in the training manual, specifically Unit 5 (https://farcry.jira.com/wiki/display/FCDEV60/UNIT+05+-+Content+Types). The properties in the rule, would be your configuration options. For your example, a Google map, you might have a field to hold the address you would like to use to add a map point, or perhaps coordinates to use to center it, among other configuration options that the Google Maps API has. You could look at the code for the Google Maps plugin that I pointed you to earlier for an example. Or, for a simpler example, I have a Poll plugin for FarCry that has a simple rule to place the poll on a page. You can see that code here: https://github.com/seancoyne/FarCry-Polling-Plugin/blob/master/packages/rules/rulePoll.cfc

In that example, you will see it has one field. That field points to the ID of a poll you have created. This is the poll that will be displayed.

Once you have created your CFC, you will need to deploy those changes to the database using the COAPI manager. See the unit on content types for information on this if you haven't done it before.

You might ask next, how does that get displayed to the user?

Well, all rules have an "execute.cfm" webskin. This webskin is, well, executed by FarCry when the rule is displayed. You place this CFM file in your /farcry/projects/yourproject/webskins/ruleYourRule/ folder. The poll rule's execute.cfm file is here: https://github.com/seancoyne/FarCry-Polling-Plugin/blob/master/webskin/rulePoll/execute.cfm

You can see, this is just a simple CFM file. It checks to make sure the ID of the poll is a valid UUID, checks if the user has submitted the poll, and if so, handles the response, and shows the results. If they are not submitting it, it simply displays the poll by loading the Poll's "displayPoll" webskin. For a Google Map rule, you would make calls to the API, passing along your configuration options, and perhaps output HTML that it needed in order to display. All your configuration options will be available via the stObj struct within your webskin. In my Poll rule example, note the use of stObj.pollid.

Lastly, you would want to know how to actually get that rule on the page. For this, you need to have containers in your display pages. The Mollio webskin examples that ship w/ FarCry have plenty of examples of these. Just look for <con:container ... /> tags. Any where there is a container, you can place a rule. Most FarCry sites have many containers scattered about the site, in the main content areas, in sidebars, headers, footers, etc.

Once you log into FarCry's webtop, if you visit any page on your site, you will see the tray at the bottom of the page (or the top depending on how you have it placed). If you click the "Rules" button on the right hand side, this will turn on design mode. In design mode, you can see all the containers. You can click a container's plus button to add a rule. You would select your rule. It would show you a form w/ your configuration options, and after save, FarCry will add that rule to the page. When the page is viewed, FC will execute your execute.cfm for that rule.

There is additional information about rules, from a content administrators point of view in the PDF training manual which you can find here: https://farcry.jira.com/wiki/download/attachments/12451867/FC60-training-manual.pdf?version=1&modificationDate=1299903122723

Please note that this response was not meant to be an all-encompassing tutorial on building rules, but I hope it points you in the right direction, and by all means, if you have specific questions, please post them here. There are lots of folks willing to help. Perhaps, if I find the time, I will prepare a blog post with step-by-step examples for creating a simple rule and deploying it to a FarCry site.