home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 139 / dpcs0999.iso / Web / CFserver / data1.cab / Examples / publish / GetObject.cfm < prev    next >
Encoding:
Text File  |  1999-04-12  |  2.2 KB  |  68 lines

  1. <CFSETTING ENABLECFOUTPUTONLY="YES">
  2.  
  3. <!--- Get full object data --->
  4.  
  5.  
  6. <!--- Pour this object's data into an associative array.
  7.  
  8.     For example, Object 132 might have the following content:
  9.     
  10.     ObjectID   Type    Data
  11.     ---------  ------  -----------
  12.     132           Title   "This Story's Title"
  13.     132           Teaser  "Read this interesting article"
  14.     132        Body    "The main story would go here."
  15.  
  16.     This is in query form.  The corresponding associative
  17.     array would look like this:
  18.     
  19.     Key     Value
  20.     ------  -----------
  21.     Title   "This Story's Title"
  22.     Teaser  "Read this interesting article"
  23.     Body    "The main story would go here."
  24.     
  25.     This enables us to access the different content
  26.     by referring to StructName.Title, StructName.Teaser,
  27.     etc. rather than doing a new query each time we 
  28.     want to access a Title, Teaser, etc.
  29.     
  30.     Once the associative array is built, it is made accessible
  31.     to the calling template so that the object can be rendered
  32.     into HTML. --->
  33.  
  34. <!--- This query retrieves all content information
  35.     for the current object --->
  36. <CFQUERY DATASOURCE="CFexamples" NAME="GetContent">
  37. SELECT PubContent.*, PubContentTypes.*
  38. FROM PubContent, PubContentTypes
  39. WHERE PubContent.TypeID = PubContentTypes.TypeID
  40.     AND ObjectID = #Attributes.ObjectID#
  41. </CFQUERY>
  42.  
  43. <!--- This is the struct that will hold our object --->
  44. <CFSET Object = StructNew()>
  45.  
  46. <!--- Loop over the GetContent query; for each row, insert
  47.     a row into the Content struct, with TypeName as the key
  48.     and Data as the value --->
  49. <CFLOOP QUERY="GetContent">
  50.     <CFSET Temp = StructInsert(Object, TypeName, Data)>
  51. </CFLOOP>
  52.  
  53. <!--- The ObjectID should also be part of the struct. --->
  54. <CFSET Object.ObjectID = Attributes.ObjectID>
  55.  
  56. <!--- Make the object accessible to the calling template. --->
  57. <CFSET Caller.Object = Object>
  58.  
  59. <!--- The CurrObject struct now contains all the content for the
  60.     current object, so it is easily accessible. Now the only
  61.     thing left to do is render the content to HTML.
  62.     Note that different classes of objects (text, file,
  63.     link) are outputted in different ways; if you were
  64.     to create your own custom object classes, you'd have
  65.     to hard-code how they are rendered, just like the
  66.     classes below. --->
  67.     
  68. <CFSETTING ENABLECFOUTPUTONLY="NO">