Menu.csp

To download the CSP files from this tutorial, click TutorialSamples_vb.zip. For more information about using the samples, see Code examples.


<HTML>

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=charset=UTF-8">

<BODY>

<!-- #Include file=RetrieveIStore.csp -->

<%



Function RetrieveFullPath(FolderID, IStore, Success)

'This function returns an HTML string that provides links

'to all of the parent folders for the current folder.

'The root folder is called 'Home'.

'

'Precondition:

'FolderID - The ID of the folder currently being viewed.

'IStore - The InfoStore object required to interface with server.

'Success - True if no error, False otherwise.


'

'Postcondition:

'Error - Contains the error: 0 if successful.


'

'Notes:

'The function returns an HTML string.


    

    Dim Query

    Dim Result

    Dim Path

    

    Path = ""


    If FolderID = 0 Then

            'This is the root folder. It has no name, so we will call it 'Home'.

            RetrieveFullPath = "<a href='home.csp?FolderID=0' target='_top'>Home</a>"

        Success=TRUE

        Exit Function

    End If

        

    'A query that selects the parent folder's ID.

    Query = "Select SI_PATH, SI_NAME From CI_INFOOBJECTS Where " & _

     "SI_ID =" & CStr(FolderID)

        

    

On Error Resume Next

    'Query the server.

    Set Result = IStore.Query(Query)

    If Err.Number <> 0 Then

        'There was an error querying the server.

        Success=FALSE

        Exit Function

    End If

        

    Dim FullPath    

    'Just in case something went wrong, check to see that you have a folder.

    If Result.Count > 0 Then

    

        'The number of parent folders.

        Dim NumFolders

        NumFolders = Result.Item(1).Properties("SI_PATH").Properties("SI_NUM_FOLDERS")

    

        'The HomeLink variable is used to to prefix the complete path with a link to the root folder.

        HomeLink = "<A HRef='home.csp?FolderID=0' Target='_top'>Home</A>"

    

        'The full path must at least include the folder we are in.

        Dim CurrentName

        CurrentName = Server.HTMLEncode(Result.Item(1).Title)

    

        'This variable represents the current folder.

        Dim CurrentFolder

        CurrentFolder = "<A HRef='home.csp?FolderID="&CStr(FolderID) & "' Target='_top'>" & CurrentName & "</A>"

        FullPath = HomeLink & " / " & CurrentFolder


        If  NumFolders > 0 then

            Dim k, ParentID, ParentName


            'This loops retrieves all the current folder's parent folders and concatenates them into

            'a complete path of hyperlinks to each of the folders.

            FullPath = ""

            For k = 1 to NumFolders

                 'Retrieve the parent's ID.

                ParentId = Result.Item(1).Properties("SI_PATH").Properties("SI_FOLDER_ID" & CStr(k))

                

                'Retrieve the parent's name.

                ParentName = Result.Item(1).Properties("SI_PATH").Properties("SI_FOLDER_NAME" & CStr(k))

                ParentName = Server.HTMLEncode(ParentName)

                FullPath = "<A HRef='home.csp?FolderID="&CStr(ParentID) & "' Target='_top'>" & _

                ParentName &   "</A>" & " / " & FullPath

            Next

            

            'Now that you have a complete path of the parent folders to the current folder,

            'create the full path prefixed with the home link and suffixed with the current folder link.

            FullPath = HomeLink & " / " & FullPath & CurrentFolder

        End If    

        Success=TRUE

        Else

        Success=FALSE

    End If  

    RetrieveFullPath = FullPath

End Function


Dim IStore

Dim CurrentFolderID

Dim Success


'Retrieve the CurrentFolderID from the file's parameter list.

CurrentFolderID = Request.QueryString("FolderID")


Response.Write "<TABLE Width='100%'><TR>"


'Try and retrieve the InfoStore object.

If RetrieveIStore(IStore)=FALSE then

    'If it failed redirect the user to the logon page.

    Response.Redirect "LogonForm.csp"

    


Else

  Dim FolderPath

  FolderPath= RetrieveFullPath(CurrentFolderID, IStore,Success)

  If Success Then

    Response.Write "<TD>" & FolderPath & "</TD>"

  Else

    Response.Write "There was an error trying to retrieve the full path of the folder."

  End If


End If

    

    'Write the link to the search page.

    Response.Write "<TD Align='right'><A HRef='searchform.csp' Target='Main'>Search</A></TD></TR>"

    'Write the link to the log off page.

    Response.Write "<TR><TD></TD><TD Align='right'><A href='Logoff.csp' Target='_top'>Logoff</A></TD></TR></TABLE>"



%>

</BODY>

</HTML>




Crystal Decisions, Inc.
http://www.crystaldecisions.com
Support services:
http://support.crystaldecisions.com