Creating the Menu

Menu

The menu is used to navigate through the site pages. As this menu will be dynamically generated from the database, we'll have to create a database connection that will handle all the requests made by the KTMLtutorial website to the tutorial database, which will be used to keep the information to be published.

To create a connection, go to the Databases tag from the Application panel, click the "plus" button and select ADODB connection.

In the configuration window that appears, you will have to fill out some fields describing the connection to be created. The Connection Name field will contain the name of the connection used for this application: tutorial, the Database Type will specify the type of the database server, which, in our case, is MySQL. The database server requires the computer name or IP address of the machine running the database server described above, in our case is remus.iakt.ro. You will also have to specify a User Name, in our case root, a password and the database name which, for this website, will be tutorial. The database Locales Fields will decide the date format (Ex. m-d-Y or d-m-Y), the messages locales and the type of connection, which can be connection (a standard connection that expires once you leave the page) or permanent connection (it uses the PHP pconnect() function to create a persistent connection).

First, we will create a recordset (rsPages) with all records from the pages_pag table. Go to Bindings (the panel from the right), click the "plus" button and choose Recordset (Query). Here are two screenshots that will help you do that.

The menu is formed by several links extracted from the database.

The first link in the menu is for the Home Page and it is a static one. Edit the page, write Home Page and then hit Enter. Select the text, right click and choose Make Link. Select showpage.php and hit OK button.

To display all the records (links), we'll use a repeated region. Before this, we should first construct the region that we want to repeat.

Go to Bindings where you created the recordset and expand it. Drag the field rsPages.menu_pag on the page under the Home Page link (the menu_pag field specifies what a menu link should contain) and then hit Enter. Now select this field, right click on it and choose Make Link. Select the file showpage.php. Once the link was created we'll use the Go To Detail Page server behavior to open every link from the menu in the right frame (mainFrame). Select the link and go to Server Behaviors (right next to Bindings), click the "plus" button and choose Go To Detail Page.

A new configuration dialog box will appear. From the Link popup menu choose the link you've just created. Set the detail page as showpage.php. For Pass URL Parameter choose id_pag (we pass the ID of the page that will be displayed in the right frame). For the Recordset and Column options, use rsPages and id_pag. Finally, check Pass Existing Parameters URL Parameters. Click the OK button.

Next we need to specify that the detail page should be opened in the right frame. To do that, select the link previously created and go to Properties Inspector ay the bottom of the page and fill in the Target with “mainFrame”.

Do the same thing for the Home Page link with a little difference. Follow the screenshot for this.

As you can see from the screenshot we also added ?id_pag=0. This is used for transmitting the URL parameter manually (like at Go To Detail Page), because the first page is static and there is no id_pag for it in the database.

Now all we need to do is create the repeated region. Select the second link and the blank line under it. After selecting it, go to Server Behaviors, click the "plus" button and choose Repeated Region. Select rsPages from the popup menu and the All Records for Show option and then click OK.

Now save the page and test it in the browser.

Adobe acquired InterAKT
InterAKT has been acquired by Adobe.
Learn more
 
© Adobe Systems Romania. All rights reserved.