'#Reference {A3B5C45B-F842-44fc-A5E5-50CED69BA86E}#2.0#0#C:\Program Files\Mindjet\MindManager 6\Mm5WebExport.dll#Mm5webexport 2.0 Type Library
'#Uses "ParameterNames.mmbas"
'#Uses "GlobalUtilities.mmbas"

Option Explicit

Sub Main

    Dim addin As Mm5WebExportAddIn
    Dim webex As WebExport
    Dim aPage As Mm5WebExportLib.Page

    Set addin = WebExportHelper.WebExportAddIn
    Set webex = addin.ActiveWebExport

    Dim count As Long
    Dim template As String
    Dim topicString As String
    Dim bodyString As String

    On Error GoTo ReportError
    
    webex.Trace("Entering SoBody.mmbas", 2 )

    ' Get our list of topics for this page
    Set aPage = webex.ActivePage
    count = aPage.TopicCount

    ' We need to adjust the rowspan for the contents table cell depending on how 
    ' many topic items we put on the page. We need rowspan equal to number of topics plus 
    ' 1 for the breadcrumbs and plus 1 for the top command plus 1 for the topic divider
    'webex.SetParameter( "CustomParameter.NumberOfTopicsOnPage" , count + 3 )

    If aPage.Type <> wePageTypeCallout Then
        ' Read our template
        template = webex.ReadFile("SoBody.htm")
        topicString = template
        ProcessString webex, topicString ' Process all commands and parameters
        bodyString = topicString
        bodyString = Replace(bodyString, "#OutlineWidth#", "190")
    Else
        ' Read our template
        template = webex.ReadFile("SoBodyCo.htm")
        topicString = template
        ProcessString webex, topicString ' Process all commands and parameters
        bodyString = topicString
    End If

    ' Write out the result
    webex.PushString( bodyString )
 
    webex.Trace( "Exiting SoBody.mmbas", 2 )

    Exit Sub
 
ReportError:
    ProcessError(webex)
    Exit Sub
 
End Sub

