home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 April / APC443.iso / features / grpware / coldfus / coldfusi.exe / data1.cab / Examples / publish / ShowObject.cfm < prev    next >
Encoding:
Text File  |  1998-10-08  |  3.3 KB  |  94 lines

  1. <CFSETTING ENABLECFOUTPUTONLY="YES">
  2.  
  3. <!--- Show full object --->
  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. <!--- This query retrieves all content information
  31.     for the current object --->
  32. <CFQUERY DATASOURCE="CFexamples" NAME="GetContent">
  33. SELECT PubContent.*, PubContentTypes.*
  34. FROM PubContent, PubContentTypes
  35. WHERE PubContent.TypeID = PubContentTypes.TypeID
  36.     AND ObjectID = #Attributes.ObjectID#
  37. </CFQUERY>
  38.  
  39. <!--- This is the struct that will hold our object --->
  40. <CFSET Object = StructNew()>
  41.  
  42. <!--- Loop over the GetContent query; for each row, insert
  43.     a row into the Content struct, with TypeName as the key
  44.     and Data as the value --->
  45. <CFLOOP QUERY="GetContent">
  46.     <CFSET Temp = StructInsert(Object, TypeName, Data)>
  47. </CFLOOP>
  48.  
  49. <!--- The ObjectID should also be part of the struct. --->
  50. <CFSET Object.ObjectID = Attributes.ObjectID>
  51.  
  52. <!--- The CurrObject struct now contains all the content for the
  53.     current object, so it is easily accessible. Now the only
  54.     thing left to do is render the content to HTML.
  55.     Note that different classes of objects (text, file,
  56.     link) are outputted in different ways; if you were
  57.     to create your own custom object classes, you'd have
  58.     to hard-code how they are rendered, just like the
  59.     classes below. --->
  60.     
  61. <CFOUTPUT>
  62.  
  63.     <DIV CLASS="HeadlineFull">#Object.Headline#</DIV>
  64.  
  65.      <BR>
  66.  
  67.     <CFIF IsDefined("Object.Image")>
  68.         <P><IMG SRC="binarydata/#Object.Image#">
  69.     </CFIF>
  70.  
  71.     <CFIF IsDefined("Object.Body")><DIV CLASS="BodyFull">
  72.         <CFIF IsDefined("Object.InlineImage")>
  73.             <IMG SRC="binarydata/#Object.InlineImage#" ALIGN="LEFT" HSPACE="10">
  74.         </CFIF>
  75.         #Object.Body#</DIV>
  76.     </CFIF>
  77.  
  78.      <BR>
  79.  
  80.     <CFIF IsDefined("Object.HREF")>
  81.         <DIV CLASS="LinkFull"><B>Go to:</B> <A HREF="#Object.HREF#">#Object.HREF#</A><BR></DIV>
  82.     </CFIF>
  83.     <CFIF IsDefined("Object.File")>
  84.         <DIV CLASS="LinkFull"><B>Download:</B> <A HREF="binarydata/#Replace(Replace(URLEncodedFormat(Object.File),"%2E",".","ALL"),"+","%20","ALL")#">#Object.File#</A><BR></DIV>
  85.     </CFIF>
  86.  
  87.     <!--- If browser is in Admin mode, display editing icons --->
  88.     <CFIF IsDefined("Cookie.PubAdminMode")>
  89.         <BR><A HREF="admin/properties.cfm?ObjectID=#Attributes.ObjectID#"><IMG SRC="open.gif" WIDTH=16 HEIGHT=14 BORDER=0 ALT="Open" ALIGN="TOP"></A> <A HREF="admin/deleteobject.cfm?ObjectID=#Attributes.ObjectID#" onClick="return confirm('This will PERMANENTLY delete this object!\n\nSure you want to continue?')"><IMG SRC="delete.gif" WIDTH=15 HEIGHT=16 BORDER=0 ALT="Delete" ALIGN="TOP"></A>
  90.     </CFIF>
  91.  
  92. </CFOUTPUT>
  93.  
  94. <CFSETTING ENABLECFOUTPUTONLY="NO">