[Gambas-user] (Gambas-)Variables in WebPages
Hans Lehmann
hans at gambas-buch.de
Wed Oct 26 14:49:13 CEST 2022
Hello,
I have a question today about working with WebPage class:
I would now like to outsource the navigation to a separate WebPage
IncNavigation.webpage. Its content should replace the source text
<nav>...</nav> marked in red.
Question:
Is there any way to use the variables declared in Main.webpage
(sCurSite, aSiteList) also in the WebPage IncNavigation.webpage?
With kind regards
Hans
--------------------------------------------------
<!-- Variable declaration must come before any HTML -->
<%
Dim i As Integer
Dim sCurSite, sNavItem, sLink As String
Dim aSiteList As New String[]
System.Language = Request.Language
' Insert a list to filter the pages
aSiteList = ["Home", "Environment", "DBReport", "Multimedia",
"Formular", "DPreise", "Random", "FPlotter", "Impressum"]
If Request.Query Then
If aSiteList.Exist(Request.Query) Then
sCurSite = Request.Query
Endif
Else
sCurSite = "Home"
Endif
%>
<!doctype html>
<html lang="de">
<!-- BEGIN SITE-HEAD
------------------------------------------------------- -->
<<IncHeadP1>>
<title><%= sCurSite %></title>
<<IncHeadP2>>
<!-- END SITE-HEAD
--------------------------------------------------------- -->
<body onload="startTime()">
<<IncHeader slogan="Webseiten mit Gambas-Webpage erzeugen">>
<br>
<!-- BEGIN SITE-NAVIGATION
------------------------------------------------------------------------------
-->
<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>
<!-- END SITE-NAVIGATION
--------------------------------------------------------------------------------
-->
<main>
<br>
<!-- BEGIN CONTENT -->
<% Select Case Request.Query
Case "Environment" %>
<<IncEnvironment>>
<% Case "DBReport" %>
<<IncDBReport>>
...
<<IncImpressum>>
<% Default %>
<<IncHome>>
<% End Select %>
<!-- END CONTENT -->
</main>
<<IncFooter>>
</body>
</html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20221026/3f06c75b/attachment.htm>
More information about the User
mailing list