Versions Compared

Key

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

...

Mockup
SuperPowerFullDisplay
SuperPowerFullDisplay
11

...

Type Webskins (aka List Views)

A "type" or "list" webskin is a special type of view that is bound to the content type and not a specific content item. They're often used to list multiple objects of a specific type. For example, the listing of Super Groups in the next walkthrough.

Type webskins should be prefixed with "displayType". Any webskin with this prefix will be available to attach to a navigation folder in the site overview tree.

Tip

Type webskins do not have a specific database record associated with them; it's effectively a view on the type itself rather than a content item. However, they still have an stobj structure - it's not normally referenced and contains system properties that be useful in more advanced templating.

Building Queries with getContentObjects()

Note

There are a couple of dopplegangers for this functionality in core, buried in FourQ and the database gateways. Both are awkward, and offer little more than arguments for the where and order by clauses. All are now deprecated and replaced with getContentObjects() from FarCry 6.0.1.

Of course you can always write your own SQL statement if you have to, but rather than building a query in your view or writing a specific function for your content type, consider using the mighty getContentObjects() – it's awesome.

application.fapi.getContentObjects() massively improves on older methods by:

  • using dynamic arguments for filtering
  • handling filters on date columns that can have null values
  • automatically filtering results by their status
  • using cfqueryparam for all filter values

The arguments are:

  • typename (req)
  • lProperties (default=objectid)
  • status (default=request.mode.lValidStatus)
  • orderBy (default=unordered)
  • property filters*

Property filters are arguments in the form propertyname_comparison=value. Supported comparisons are:

  • eq, neq (equality filters)
  • in, notin (list filters)
  • like (standard DB like comparison)
  • isnull (boolean value to specify whether to return null properties or not)
  • gt, gte, lt, lte (standard comparisons, null dates always pass these filters)
Code Block
titleExamples getContentObjects() in Action

qLatestNews = application.fapi.getContentObjects(typename="dmNews",lProperties="objectid,title",publishDate_lt=now(),expiryDate_gt=now(),orderBy="publishDate desc") 
qLockedHTML = application.fapi.getContentObjects(typename="dmHTML",locked_eq=1) 
qNotActiveUsers = application.fapi.getContentObjects(typename="dmUser",userstatus_in="inactive,pending")
Tip
titleapplication.fapi

application.fapi has a bunch of great short cuts to more complex areas of the FarCry framework and APIs. The FAPI should be the first place you look for doing anything vaguely tricky (smile)

Walkthrough: List of Super Groups (typewebskin)

  1. Create a new webskin in /webskins/superGroup and call it "displayTypeBody"
  2. Update the displayname with "Standard Type ListingSuper Group List"
  3. Generate a listing of Super Groups, using something similar to the code below:
    Code Block
    title./myproject/webskins/superGroup/displayTypeBody.cfm
    <cfsetting enablecfoutputonly="true" />
    <!--- @@displayname: Super Group List View --->
    
    <!--- tag libraries --->
    <cfimport taglib="/farcry/core/tags/webskin/" prefix="skin" />
    
    <cfoutput><h1>Super Groups</h1></cfoutput>
    
    <cfquery datasource="#application.dsn#" name="qGroups">
    SELECT objectid FROM superGroup
    ORDER BY title
    </cfquery>
    <!--- get query of super groups --->
    <cfset stlocal.qGroups = application.fapi.getContentObjects(typename="superGroup",orderBy="title") 
    
    <cfoutput><h1>Super Groups</h1></cfoutput>
    
    <cfloop query="stlocal.qGroups">
      <skin:view typename="superGroup" objectid="#qGroups#stlocal.qGroups.objectid#" webskin="displayTeaserStandard" />
    </cfloop>
    
    <cfsetting enablecfoutputonly="false" />
    
  4. Build out a displayTeaserStandard (called from the listing above) for Super Groups to show in this list:
    Code Block
    <cfsetting enablecfoutputonly="true" />
    <!--- @@displayname: Super StandardGroup Teaser for superGroup --->
    
    <!--- tag libraries --->
    <cfimport taglib="/farcry/core/tags/webskin/" prefix="skin" />
    
    <cfoutput>
    <div class="featurebox">
    	<div class="thumbnailLeft">
    		<skin:buildLink objectid="#stobj.objectid#">
    		<img src="#application.url.webroot##stobj.imgHeadQuarters#" alt="#stobj.title#" title="#stobj.title#" />
    		</skin:buildLink>
    	</div>
    
    	<br class="clear" />
    </div>
    </cfoutput>
    
    <cfsetting enablecfoutputonly="false" />
    
  5. Reload the COAPI Metadata
    Tip

    You can reference the type skin or list view on the URL with something like the following convention: http://greyhamelocalhost:8888/jumpstart/index.cfm?type=superGroup&view=displayTypeBody

  6. Login to the webtop and open the Site overview tree; we're going to hook our type view into the site menu structure
  7. Locate the "Hero Hotline" navigation folder, and delete the "Hero Hotline" HTML Page **NOT THE NAVIGATION FOLDER.... THE HTML PAGE (wink) **
  8. Create a new Include item: right mouse click on the Navigation folder or select Create Include from the right hand menu accordion
  9. Fill in the fields for the Include, calling it "Hero Hotline"
  10. Under OPTION 1, select the type "Super Group" and the type webskin "Display Type Listing"
  11. Preview this page in your site

...