Implementation
So how does this all work? First, create an ASP file and add that file to a resource gallery to which your users have access. For the purposes of this exercise, we're going to use TEST.ASP, which has the following code in it:
<% Response.write "This is the code you've added.<br>" Response.write "The name of this server is: " & _ Request.Servervariables("HTTP_HOST") %>
The above code simply writes out the following lines, replacing [server name] with the name of your server at runtime:
This is the code you've added. The name of this server is: [server name]
How do you get from this ASP page to a place where your users can add this content to a placeholder and have the result display as a unified posting within a site?
First, make a copy of one of your existing templates or create new one. For the following example, I'll create a new template, based on an existing one. For the purposes of demonstrating a concept, I'll simply create this new template with a single attachment placeholder called attAttachment. Once I've created the new template and added my placeholder, I place the following code in my template:
<% Dim pPlaceholders, pPlaceholder Set pPlaceholders = Autosession.ThisPosting.Placeholders Set pPlaceholder = pPlaceholders.Item("attCodeSnippet") If IsEditing() then%> <h1>Enter Attachment Here:</h1> [insert your placeholder called "attCodeSnippet" here] <% elseif not(iswbceditmode()) and not(IsEditing()) then Response.write "<h1>Publish Date: " & _ DisplayDate(Autosession.ThisPosting.StartDate) & "</h1>" Response.Write "Last Modified: " & _ DisplayDate(Autosession.ThisPosting.LastModifiedDate) & "<p>" Server.execute GetFileURL(pPlaceholder.GetHTML) Else Response.write "<b>Code Snippet to Execute:</b><BR>" & _ GetFileName(pPlaceholder.GetHTML) & "<P>" end if %>
In the above code, I'm doing a few things:
I'm checking for the state of my current sessionam I authoring, in edit mode (the placeholder isn't exposed, but I see the edit console), or is this posting live?
If my posting is live, I'm going to execute the ASP page attached to this posting.
If I'm in edit mode, I'm simply going to display which ASP page has been attached to my posting.
If I'm authoring, I'm going to display the placeholder and allow my content contributors to add to and/or change the ASP page attached to this posting.
NOTE
The functions included in the above code sample are provided at the end of this article.
After building your template, save and exit. When you're back in the Site Builder interface, you'll have your new template. Make sure that you set the placeholder to a "single attachment" placeholder. Once you've done that, you just need to approve it before you move on to the next step.
Once the template is saved and approved, open a web browser session and follow the steps below:
Navigate to your web site.
Log in (as an administrator) if the site doesn't automatically authenticate you.
Switch to edit mode.
Once in edit mode, click Create New Page.
From the template gallery, select your new template.
Click the paper clip icon to add the attachment to the placeholder.
Select the option to insert a shared resource.
Find the gallery where you stored your ASP page.
Choose the ASP file that you saved in the resource gallery.
Save your new posting and exit.
When your new posting renders in edit mode, you should see the filename of the ASP file you added.
After you approve the posting and switch to live mode, you'll see the posting fully rendered with the ASP file's content.