[Gambas-user] (Gambas-)Variables in WebPages
Hans Lehmann
hans at gambas-buch.de
Wed Oct 26 19:51:12 CEST 2022
Hello,
the solution is to define a variable in the Main.class and initialise it
with the intended values:
' Gambas class file
Public SiteList As String[] = ["Home", "Environment", "DBReport",
"Multimedia", "Form", ... , "FPlotter", "Imprint"]
In another webpage - here IncNavigation.webpage - you can then use
aSiteList = Main.SiteList
and use the values of the array aSiteList in the navigation:
<%
Dim aSiteList As New String[]
Dim sCurSite, sLink, sNavItem As String
Dim i As Integer
aSiteList = Main.SiteList
If Request.Query Then
If aSiteList.Exist(Request.Query) Then
sCurSite = Request.Query
Endif
Else
sCurSite = aSiteList[0]
Endif
%>
<nav class="site-nav">
<!-- Umschaltung mit dem Toogle-Button zwischen horizontalem und
vertikalem Menü bei SCREEN < 600px -->
<!-- Switching with the Toogle button between horizontal and vertical
menu at SCREEN < 600px -->
<button class="menubutton"
onclick="this.classList.toggle('showmenu')">Menü</button>
<ul>
<%
For i = 0 To aSiteList.Max
If aSiteList[i] = sCurSite Then
sLink = Application.Root & "?" & sCurSite
sNavItem = "<li class=" & Chr(34) & "site-current" & Chr(34)
& "><a href=" & Chr(34) & sLink & Chr(34) & ">" & sCurSite & "</a></li>"
Print sNavItem
Else
sLink = Application.Root & "?" & aSiteList[i]
sNavItem = "<li><a href=" & Chr(34) & sLink & Chr(34) & ">"
& aSiteList[i] & "</a></li>"
Print sNavItem
Endif
Next
%>
</ul>
</nav>
Regards,
Hans
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20221026/7efe53c8/attachment.htm>
More information about the User
mailing list