Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert menu in template problem

Status
Not open for further replies.

alienguy

Programmer
Jun 8, 2007
1
CA
Hi All,

I'm trying to use the replace function to insert the menu into an template but it places the menu at the top of the page and not where is should.
Here is the function that does the replacing. Below is the menu code. I have tried 50 ways to get it right and no luck.

Any help would be great...

Function InsertContent(templatebody)
Set ASConn = CreateObject("ADODB.Connection")
ASConn.Open DataSource1
Set objRec1 = CreateObject("ADODB.Recordset")
If ID = "" or Not isNumeric(ID) or ID = "%" Then
SQL = "select * from sitepages where pageid="&cINT(Session("ID"))
else
SQL = "select * from sitepages where pageid=1"
end if
objRec1.Open SQL, ASConn, 3
If not objRec1.EOF then

dim skeywords,sdescription,pagetext,textbody
skeywords=objRec1("skeywords")
sdescription=objRec1("sdescription")
pagetext=objRec1("pagetext")
textbody=objRec1("textbody")

templatebody1 = templatebody

templatebody1 = Replace(templatebody1,"{keywords}", ""&skeywords&"", 1, -1, 1)
templatebody1 = Replace(templatebody1,"{description}", sdescription, 1, -1, 1)
templatebody1 = Replace(templatebody1,"{textbody1}", ""&textbody&"", 1, -1, 1)
templatebody1 = Replace(templatebody1,"{pagename}", ""&pagetext&"", 1, -1, 1)
templatebody1 = Replace(templatebody1,"{dateinc}",""&FormatdateTime((Date),1)&"")
templatebody1 = Replace(templatebody1,"{yy}",""&DatePart("yyyy",Now())&"")

if inStr(1, templatebody1, "{menu}", 1) > 0 then
strNewMenu = ReplaceMenu(tb)
templatebody1 = replace(templatebody1, "{menu}", strNewMenu)
end if

InsertContent = templatebody1
objRec1.Close
Set objRec1=Nothing
Set ASConn=Nothing
else
Response.Write "No Page Information"
objRec1.Close
Set objRec1=Nothing
Set ASConn=Nothing
end if
End Function

'===================================

'===================menu=================
Function ReplaceMenu(tb)

Set ASConn = Server.CreateObject("ADODB.Connection")
ASConn.Open DataSource2
%>
<link rel="STYLESHEET" type="text/css" href="lionsmenu.css">
<script language=javascript>
<!--
function clickCategory(CatIDStr)
{
var txtObj = document.all("t_" + CatIDStr);
var imgObj = document.all("i_" + CatIDStr);

if (txtObj.style.display == 'none')
{
txtObj.style.display = '';
imgObj.src = 'images/node_minus.gif';
}
else
{
txtObj.style.display = 'none';
imgObj.src = 'images/node_plus.gif';
}
}
//-->
</script>
<table cellspacing="0" cellpadding="0" border=0>
<tr>
<td>
&nbsp;<font size=1><b>Navigation:</b></font>
<br><br>
<%
strSQL = "select * from tblTreeMenu where Parent=0 and showintree=1 order by treeorder, FolderName, ID"
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.Open strSQL, ASConn, adOpenStatic, adLockReadOnly, adCmdText
If Not objRec.EOF Then
objRec.MoveFirst
Do While Not objRec.EOF

If NumOfSubs(objRec("ID")) > 0 Then %>
<span title="<%=objRec("Description")%>">
<img src="images/trans.gif" width=9 height=9 alt="" border="0"><img id="i_treeid_<%=objRec("ID") %>" onclick="clickCategory('treeid_<%=objRec("ID") %>')" src="images/node_plus.gif" border=0>
<a href="<%If objRec("LinkLocation")<> "" Then%>default.asp?contentid=<%=objRec("ID")%><%Else%>#<%End If%>" class="TreeMenu" onclick="clickCategory('treeid_<%=objRec("ID") %>');"><b><%=objRec("FolderName") %></b></a></span><br>
<% Else %>
<span title="<%=objRec("Description")%>">
<img src="images/trans.gif" width=9 height=9 alt="" border="0"><img src="images/node_final.gif" width=9 height=9 alt="" border="0">
<a href="<%If objRec("LinkLocation")<> "" Then%>default.asp?contentid=<%=objRec("ID")%><%Else%>nolink.asp?menu=<%=objRec("ID") %><%End If%>" class="TreeMenu"><b><%=objRec("FolderName") %></b></a></span><br>
<% End If
If NumOfSubs(objRec("ID")) > 0 Then
response.write""&DisplaySubs(objRec("ID"))&""
End If
objRec.MoveNext
Loop
End If
objRec.Close
Set objRec = Nothing
%>
<br>
</td>
</tr>
</table>
<%
If Request("menu") <> "" Then
varOpenMenu = Request("menu")
Do While varOpenMenu <> 0
%>
<script>
clickCategory('treeid_<%=varOpenMenu%>')
</script>
<%
strSubOpen = "select * from tblTreeMenu where ID="&varOpenMenu&" and showintree=1 order by treeorder, FolderName, ID"
Set objSubopen = Server.CreateObject("ADODB.Recordset")
objSubOpen.Open strSubOpen, ASConn, adOpenKeyset, adLockOptimistic, adCmdText
varOpenMenu = objSubOpen("Parent")
objSubOpen.Close
Set objSubOpen = Nothing
loop
End If
'templatebody= ReplaceMenu(tb)
ReplaceMenu = tb
End Function

'=========================================================
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top