Home > Articles > Web Development > Content Management Systems

Like this article? We recommend

Like this article? We recommend

Parting Thoughts

  • The code in this article is provided as is, with no warranties either expressed or implied.

  • This example should run in a load-balanced environment, but it was only tested on a single, non-load-balanced web server running CMS 2001, Windows 2000 Advanced Server, and SQL 2000.

  • If you want to embed CMS 2001 functionality in your code snippet, you'll have to treat the ASP file as out-of-process. In other words, you'll need to have a server-side include for Resolution.INC. Take a look at the CMS 2001 documentation for the exact SSI (server-side include) call.

  • This article assumes that you're familiar with building templates in CMS 2001 and that you've added EmbedEditSiteConsole and ShowSiteModeSwitch in your template.

  • Ideally, the following "helper" functions would be stored in an include file and not in the template.

The functions referenced in the code samples above are presented in Listings 1–4. To download a text file containing all four functions, click here.

Listing 1—GetFileURL()

Function GetFileURL(strHTML)
On error resume next

  '***************************************************************************
  '* Purpose:   Returns the URL of a file attachment
  '*
  '* Author:   PLURAL
  '* Date:   3/25/2002
  '*
  '***************************************************************************

  Dim intStrLen, strFileURL, strSingleChar

  intStrLen = instr(1,lcase(strHTML),"href=")
  intStrLen = instr(intStrLen + 7,lcase(strHTML), """")
  intStrLen = intStrLen - 1
  strSingleChar = mid(strHTML, intStrLen, 1)

  Do until strSingleChar = """"
   strFileURL = strSingleChar & strFileURL
   intStrLen = intStrLen - 1
   strSingleChar = mid(strHTML, intStrLen, 1)
  Loop

  GetFileURL = strFileURL

End Function

Listing 2—GetFileName()

Function GetFileName(strHTML)
On error resume next

  '***************************************************************************
  '* Purpose:   Returns the name of a file from a URL
  '*
  '* Author:   PLURAL
  '* Date:   3/25/2002
  '*
  '***************************************************************************


  Dim intStrLen, strFileURL, strSingleChar

  intStrLen = instr(1,lcase(strHTML),"href=")
  intStrLen = instr(intStrLen + 7,lcase(strHTML), """")
  intStrLen = intStrLen - 1
  strSingleChar = mid(strHTML, intStrLen, 1)

  Do until strSingleChar = "/"
   strFileURL = strSingleChar & strFileURL
   intStrLen = intStrLen - 1
   strSingleChar = mid(strHTML, intStrLen, 1)
  Loop

  GetFileName = strFileURL

End Function

Listing 3—IsWBCEditMode()

Public Function IsWBCEditMode()
On Error Resume Next

  '***************************************************************************
  '* Purpose:   Returns boolean if posting is in "edit" mode
  '*      recipient
  '*
  '* Author:   PLURAL
  '* Date:   3/25/2002
  '*
  '***************************************************************************

  ' --- Declare Variables
  dim strQuery, pPosting, bolIsWBCEditMode

  bolIsWBCEditMode = False

  set pPosting = Autosession.ThisPosting

  strQuery = Request.QueryString("wbc_purpose")

  if strQuery = "Basic" then bolIsWBCEditMode = True

  IsWBCEditMode = bolIsWBCEditMode

  '--- Destroy posting object
  set pPosting = Nothing

End Function

Listing 4—IsEditing()

Public Function IsEditing()
On Error Resume Next

  '***************************************************************************
  '* Purpose:   Returns boolean if a content contributor is authoring
  '*      recipient
  '*
  '* Author:   PLURAL
  '* Date:   3/25/2002
  '*
  '***************************************************************************

  '---Declare Variables
  Dim strQuery
  Dim pPosting
  Dim bolIsEditing

  bolIsEditing = False

  set pPosting = Autosession.ThisPosting

  strQuery = Request.QueryString("nr_emit")

  if strQuery="ThinEdit" or strQuery = "Win32Edit" then bolIsEditing = True

  IsEditing = bolIsEditing

  '---Kill Object
  set pPosting = Nothing
End Function

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.