Forums

ASP

This topic is locked

show active page link

Posted 20 Jul 2005 17:37:43
1
has voted
20 Jul 2005 17:37:43 sofie sof posted:
Hello,



Most of the time the menus of my websites are databasedriven, i use asp, people can add pages through a cms system and then the title of that page is shown as link in the menu on their website. Now i am looking for a system to show the ACTIVE link. In fact i use only one asp page with different page id's. Could someone help me out here?



Greetz,



Sofie

Replies

Replied 20 Jul 2005 18:49:16
20 Jul 2005 18:49:16 myke black replied:
Hello!

I think what you are looking for is something like this:


<pre id=code><font face=courier size=2 id=code>
set conn = server.createObject("ADODB.connection"
conn.open [connectionstring]
SQL = "select * from pages"
set rs = conn.execute(SQL)
if not rs.eof then
while not rs.eof
if rs.fields("pageID" = request.querystring("ID" then
response.write "&lt;a href=""index.asp?id=" & rs.fields("pageID" & """ style=""color:red""&gt;" & rs.fields("pageTitle" & "&lt;/a&gt;&lt;br /&gt;" ' this is the active link
else
response.write "&lt;a href=""index.asp?id=" & rs.fields("pageID" & """ style=""color:black""&gt;" & rs.fields("pageTitle" & "&lt;/a&gt;&lt;br /&gt;" ' non active links
end if
rs.movenext
wend
end if
set rs = nothing
conn.close
set conn = nothing
</font id=code></pre id=code>


you can also use CSS to set the a:active property of links differently, but that can be a bit fiddly in certain circumstances.

Replied 15 Aug 2005 18:26:15
15 Aug 2005 18:26:15 sofie sof replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hi Mike,
thanks for helping me out the other day.
I have been playing around and came up with this code, but it does not work :
&lt;%
While ((Repeat1__numRows &lt;&gt; 0) AND (NOT menu.EOF))
%&gt;
&lt;table width="100%" border="0" cellpadding="2" cellspacing="2"&gt;
&lt;tr&gt;
&lt;% if not (paginas.Fields.Item("paginaid".Value)=Request.QueryString("paginaid"then %&gt;
&lt;td class="menu"&gt;&lt;a href="pagina.asp?paginaid=&lt;%=(menu.Fields.Item("paginaid".Value)%&gt;"&gt;&lt;%=(menu.Fields.Item("paginanaam_nl".Value)%&gt;&lt;/a&gt;&lt;/td&gt;
&lt;% end if %&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;% if (paginas.Fields.Item("paginaid".Value)=Request.QueryString("paginaid" then %&gt;
&lt;td class="nieuws"&gt;&lt;a href="pagina.asp?paginaid=&lt;%=(menu.Fields.Item("paginaid".Value)%&gt;"&gt;&lt;%=(menu.Fields.Item("paginanaam_nl".Value)%&gt;&lt;/a&gt;&lt;/td&gt;
&lt;% end if %&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
menu.MoveNext()
Wend
%&gt;

if the if-statement is true i'd like the code to choose the 'nieuws' class if not the 'menu' class but it does not work

if you want to you can check on this url:www.hollandtelecenter.nl

Greetz,

Sofie






<pre id=code><font face=courier size=2 id=code>
set conn = server.createObject("ADODB.connection"
conn.open [connectionstring]
SQL = "select * from pages"
set rs = conn.execute(SQL)
if not rs.eof then
while not rs.eof
if rs.fields("pageID" = request.querystring("ID" then
response.write "&lt;a href=""index.asp?id=" & rs.fields("pageID" & """ style=""color:red""&gt;" & rs.fields("pageTitle" & "&lt;/a&gt;&lt;br /&gt;" ' this is the active link
else
response.write "&lt;a href=""index.asp?id=" & rs.fields("pageID" & """ style=""color:black""&gt;" & rs.fields("pageTitle" & "&lt;/a&gt;&lt;br /&gt;" ' non active links
end if
rs.movenext
wend
end if
set rs = nothing
conn.close
set conn = nothing
</font id=code></pre id=code>


you can also use CSS to set the a:active property of links differently, but that can be a bit fiddly in certain circumstances.


<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Reply to this topic