Thursday 9 December 2010

Displaying Server Parameters

My colleague discovered how to display a server variable (e.g. the logged on user) on a page:
  1. Insert a field from any list as a single item dataview, doesn't matter which list or which field, into your page.  We'll say you're using 'Title'
  2. Create a Parameter on that view of Parameter Type 'Server Variable' and set the Server Variable Name to the name of the variable you want to use (e.g. LOGON_VARIABLE for the username of the logged on user.
  3. In the page select the dataview you created then go to the Code view (or code pane in Split view).  look for a line that contains an at symbgol followd by the name of the field you chose.  If you used the title field it would look something like:
    <xsl:value-of select="@Title" />
  4. Replace the @ with a $ and the field name with the name of the parameter.  If the parameter name is Param1 the line will now look like:
    <xsl:value-of select="$Param1" />
  5. Save the page and view it in your browser, it should show your username.

No comments:

Post a Comment