Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Array properties in terms of how they are defined in a content type really don't differ all that much to normal properties. You add a <cfproperty> and simply define type="array" and with a list of content types that you would like to allow to be associated using ftJoin, ; for example ftJoin="superPower". However, what happens behind the scenes is much more involved.

Code Block
titleExample Array Property
<cfcomponent ..>
...
<cfproperty
	name="aPowers" type="array" hint="Array of superhuman powers."
	ftSeq="12" ftFieldset="Related Content" ftWizardStep="Relationships" ftLabel="Powers"
	ftType="array" ftJoin="superPower" />
...
</cfcomponent>

...

If you open up the database model after you deploy an array property, you'll notice that the property (for example, aPowers) is not represented by a column in the table. Array data is essentially an index of references to other objects and is defined by its own linked table (for example, superHero_aPowers). The array table includes the parent object, the referenced objectid, the sequence multiple entries should be represented in, and the typename of the referenced object. Importantly, the data model in the database itself does not need to be understood to work with arrays - the framework handles recording and retrieving this information.

...

Code Block
titleExample Multi-Type Array Property
<cfproperty
  name="aMedia" type="array" hint="Local media library." required="no" default=""
  ftSeq="13" ftFieldset="Relationships" ftLabel="Associated Media"
  ftType="array" ftJoin="dmImage,dmFile,dmFlash" />

By default the library UI control for an array property will list all content objects of the nominated type, ordered by datetimelastupdated.

...

  1. Open the ./packages/types/superHero.cfc component for editing.
  2. Add the following property
    Code Block
    <cfproperty 
    	name="aPowers" type="array"
    	ftSeq="12" ftFieldset="Related Content" ftWizardStep="Relationships" 	nameftLabel="aPowersPowers"
    	typefttype="array" 	ftLabel="Powers"
    	ftJoin="superPower"
    	hint="Array of superhuman powers." />
    
  3. Go to the webtop COAPI admin area and deploy your new property. You should see a single conflict for the Super Hero component.
    • Deploy the superPower array property.
    If you have a tool for browsing the database schema, now would be a good time to take a look at the underlying array table
    • many to many relationship (bridging table)
    • ParentID, Data, Seq, Typename
  4. Reload the COAPI Metadata
  5. Go to the Super Hero administration screen, and associate super powers from the library picker that should now be available in the edit handler.

...

By default the library will only show a content object's label, and if that's blank the objectid. However, like many aspects of the framework, this behaviour can be modified to suit your specific application. FarCry Framework has a special webskin (or view) for rendering the objects selected for the library: ./webskin/typename/librarySelected.cfm (where typename is represented by the actual typename you are trying to modify).

...

  1. Create a new webskin template ./webskin/superPower/librarySelected.cfm
  2. Copy the following code into the webskin:
    Code Block
    title./myproject/webskin/superPower/librarySelected.cfm
    <cfsetting enablecfoutputonly="true" />
    <!--- @@displayname: Power (Library) --->
    
    <cfoutput>
    <div>
    <img src="#application.url.webroot##stobj.imgPower#"  alt="#stobj.title#" title="#stobj.title#" /> #stobj.title#<br />
    #stobj.description#
    </div>
    </cfoutput>
    
    <cfsetting enablecfoutputonly="false" />
    
  3. Reload the COAPI Metadata to register the newly added webskin.
  4. Go back to the Super Hero admin and try adding super powers. Make sure your librarySelected webskin is working as expected.

...

  1. Open the ./packages/types/superHero.cfc component for editing.
  2. Add a UUID property for sidekickid
    Code Block
    title./myproject/packages/types/superHero.cfc
    <cfproperty
    	name="sidekickid" type="uuid" hint="Super hero sidekick."
    	ftSeq="11" ftFieldset="Related Content" ftWizardStep="Relationships" ftLabel="Sidekick"
    	ftType="uuid" ftJoin="superHero" />
    
  3. Go to the webtop COAPI admin area. You should see a single conflict for the Super Hero component.
    • Deploy the sidekickid UUID property.
  4. Go to the Super Hero administration screen, and associate a side-kick from the library picker that should now be available in the edit handler.

...