Showing posts with label Templates. Show all posts
Showing posts with label Templates. Show all posts

Monday, November 19, 2007

How to make a file download link in Dynamic Web

Sometimes you want the user to be able to just download a file you point to from your Dynamic Web CMS homepage. What you need to do is simple:
  • Prefix your filepath with:
    /Admin/Public/DWSDownload.aspx?File=

  • If your file is here:
    /Files/files/myFile.txt

  • Resulting URL:
    /Admin/Public/DWSDownload.aspx?File=/Files/files/myFile.txt

If the file path is written using Javascript you should
escape()
the file path.

Wednesday, October 31, 2007

Handy VS2005 macro for Dynamic Web

This VB macro is a handy utility for use in Microsoft Visual Studio 2005 when editing Dynamic Web Templates. It til insert a remark at the begining of the template which says in which directory the template is placed, and the name of it.




It also inserts a not active <!--@DwTemplateTags-->, a tag which at the time where the template is rendered, will show you which template tags are availible, and their values.





  • Copy'n'paste the code below into a file named (for instance) "DwUtils.vb"

  • Save it and import it into VS2005.



Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics

Public Module DwUtils


Sub prepareTemplate()
Dim doc As Document
Dim desc As String
Dim sName As String
Dim sPath As String
Dim i As Integer
Dim temp As Array


doc = DTE.ActiveDocument
sName = doc.Name
sPath = doc.Path
temp = sPath.Split("\")
desc = ""
For i = temp.Length - 3 To temp.Length - 1
desc = desc & "/" & temp(i)
Next
sName = desc & sName

Dim textSelection As TextSelection

textSelection = DTE.ActiveDocument.Selection
textSelection.GotoLine(1)
textSelection.Insert("" & vbCrLf)


textSelection.EndOfDocument()
textSelection.Insert(vbCrLf & "")
End Sub
End Module