Use the following steps to build the detail list:
Open the detail_list page in Dreamweaver.
Apply the NeXTensio List Wizard from the MX Kollection tab of the Insert panel.
Configure the wizard in a similar manner to the master list, but using the contacts_con table.
When you've set up the correct table, you can directly click the Finish button, as the fields to use are not as important at this time. Just remember to set the correct form page: detail_form.
As a small enhancement, you might want to remove the idcom_con field from the list presented in step 2 of the wizard, as this is the detail list for a specific company. If you decide to leave the idcom_con field to be displayed in the list, you will have to configure it to use a look-up table. For detailed instructions, consult the user manual.
Once the wizard has been applied, you will have to make some modification to the data that is retrieved by the list, so you will restrict it to the master record A database row from the master table. The master table is defined by a one-to-many relation to another table (the detail table) that has been selected in the master list.
To do so, you will have to filter the NeXTensio recordset A recordset is the result of executing an SQL query A query is a SQL command that will extract information from the tables of a database. Essentially, a query is a request for information from your database.. It is composed of multiple rows, each row having multiple columns. The columns presented in the query result depend on the column list declared in the query (they can belong to different tables). The number of rows and their order depend on the query conditions (WHERE, GROUP BY, HAVING, ORDER). The recordset acts as a source of dynamic data The InterAKT Dynamic Data tool is a replacement for the standard dynamic data dialog. It is used in the MX Kollection 3, to provide a unified way of building mark-ups, or place holders. These are recordset fields, server or session variables, and other types of dynamic data that are replaced at runtime by their corresponding values in web applications. after the id_com URL parameter that you've added to the detail link.
Double click the ListRecordset in the Bindings tab of the Application panel. Add a new variable, with the following attributes:
Name: paramIDCom
Default Value: -1
Runtime Value: $_GET['id_com']
Note: for ASP VBScript, the runtime value is Request.QueryString("id_com")
Note: For ColdFusion, the steps are slightly different:
Name: URL.id_com
Default Value: -1
Now you have to modify the existing SQL, in order to add the condition. In the SQL text area, the following code is already added by the server behavior A server behavior is a reusable component for server-side development. They add blocks of code to your pages for accomplishing specific tasks. Dreamweaver comes with several default server behaviors and the InterAKT extensions add many more to this list.:
SELECT idcom_con AS old_idcom_con, company_com.name_com AS idcom_con, contact_con.name_con, contact_con.job_con, contact_con.email_con, contact_con.phone_con, contact_con.birthday_con, contact_con.id_con, contact_con.id_con
FROM contact_con LEFT JOIN company_com ON contact_con.idcom_con = company_com.id_com
WHERE filter
ORDER BY sort
Note: if you removed the idcom_con column entirely, the SQL query is different:
SELECT contact_con.name_con, contact_con.job_con, contact_con.email_con, contact_con.phone_con, contact_con.birthday_con, contact_con.id_con, contact_con.id_con
FROM contact_con LEFT JOIN company_com ON contact_con.idcom_con = company_com.id_com
WHERE filter
ORDER BY sort
If this is the case, you have to add the idcom_con column to the query. By adding it manually, it will not be displayed in the list, but it will be available in the recordset. The new query will have to be: (new section is bold)
SELECT contact_con.idcom_con, contact_con.name_con, contact_con.job_con, contact_con.email_con, contact_con.phone_con, contact_con.birthday_con, contact_con.id_con, contact_con.id_con
FROM contact_con LEFT JOIN company_com ON contact_con.idcom_con = company_com.id_com
WHERE filter
ORDER BY sort
You need to add the following line after the WHERE filter condition:
AND contact_con.idcom_con=paramIDCom
Note: For ColdFusion, add this line after the WHERE #PreserveSingleQuotes(SESSION.filter_tfi_listcontact_con2)# condition:
AND idcom_con = #URL.id_com#
Note: the page parameter names may vary, according to each particular setup (connection name, the number of lists, and other factors)
Click on OK to close the recordset configuration dialog box.
Now you need to edit the Add new link displayed in the list's footer, so that the insert form will receive the correct company identifier. Right - click on the link, and then select the Change Link option from the pop-up menu.
The link is already defined, and it uses an URL parameter. Click on the Parameters button to add the company id to the list.
In the Parameters dialog box, add a new parameter called id_com, and for the value enter the following code:
<?php echo $_GET['id_com']; ?>
This code will retrieve the value of the existing URL parameter, and add it to the link's URL.
Note: For ColdFusion, add <cfoutput>#URL.id_com#</cfoutput> in the Value field.
Note: For ASP VBScript, use <%=Request.QueryString("id_com")%>
Now you have to set the new parameter to be the first one in the list. To do so, click on its name, and press the UP (^) arrow on top of the grid.
The same URL parameter must be added to the edit button. The cause is that when editing a record you have the option of adding it as a new one in the database, through the Add as new button. This button triggers an Insert transaction which requires the company ID to be sent. The Update transaction itself does not use the company ID at all.
Click on the OK buttons to close the two dialog boxes, and then save the page.
As the last action on the detail_list page, you must add a link that will take you to the previous page.
Although you can simply place a link that points to the master list, when using multiple levels, the correct way is to use the KT_back variable. This variable is set by the NeXTensio List, and allows any other page to return through a link.
First, to make the variable available to other pages, you must add it as an URL parameter to the Detail link on the master list page:
Open the master page.
Right-click the Detail link.
Select the Change Link option, and add a new URL parameter. Its name will be KT_back and the value equal to 1.
Now go back to the detail_list page. To create the link that will point to the previous page, follow the next steps:
First you need to include the file that contains the class definition - so that the variable will be recognized properly. For this, you need to add some code on top of the detail_list page, like the one below:
For PHP
require_once('includes/nxt/KT_back.php');
For ColdFusion:
<cfinclude template="includes/nxt/KT_back.cfm">
For ASP VBScript
<!--#include file="includes/nxt/KT_back.asp" -->
Caution:Take care to write the correct path to the includes folder, depending on which level the page that requires it is located.
After you've added the reference to the KT_back class, you can use the KT_back variable to create the link.
Type the back text below the list. Select it and right-click on it.
In the Make link dialog, set it to point to the includes/nxt/back.php page.
Also, pass it the KT_back parameter, with -2 as value.
The link in all, should look like:
includes/nxt/back.php?KT_back=-2.
Note: You must replace the php extension used in the code samples in this tutorial with the actual extension required by your particular server model - .cfm or .asp
Once the list is completed, and all the required alterations have been made to the code, you can move on and create the forms associated to the lists: the master and the detail form.