First, you'll edit the index.php file. Open it and apply the blgtemplate to it by selecting Modify > Templates > Apply Template to Page. Select the template from the list and select the "Update page when template changes" option.
In the title field of the Document bar, enter Blog: Home as the title of the page.
Since this is the home page of the site, it displays the list of the most recent articles. For this, you need to define a recordset, and then display data from that recordset in a dynamic table inserted in the editable region.
This time, you create an advanced recordset because you need to display both the articles and the associated topics.
Enter the following information in the Recordset dialog box:
Edit
the SQL query to create an inner join between the topics and articles tables on
the corresponding foreign key. Copy or write the following code immediately
after blg_article_art
:
INNER JOIN blg_topic_top ON idtop_art=id_top
(+) View larger
Note: The join operation matches records in two
tables. Match the idtop_art
foreign key from the blg_article_art
table with the primary key id_top
from the blg_topic_top
table.
The advanced recordset contains the fields of both tables, as shown in Figure 16.
Next, you need to display the data from the advanced recordset in your page.
You must remove the unnecessary columns and trim the table to a readable format.
id_art
idtop_art
text_art, id_top
description_top
. Select table columns by clicking inside the table, clicking the
down arrow above each column in the table, and selecting select column
from the pop-up menu. Then press your delete key. If you do not see the
down arrow, ensure that you have the table widths visual aid enabled (View
> Visual Aids > Table Widths). <table>
tag
from the tag selector. Set the table width to 100% in the Property
inspector.title_top
and
title_art
dynamic texts into the merged cell and separate them with a >
character.date_art
dynamic text
after it.Note: All the recordset data must be inside a repeat region. This guarantees that all the records from a recordset display iteratively.
Figure 17 shows how the final table should look in Design view.
(+) View larger
Finally, you need to link the topic names to the corresponding article lists
and the article names to the article detail page. Select the dynamic text labeled and create a
link to the topic.php file. The link must pass the
URL named
id_top
,
which takes as value the field value idtop_art
from the rsArticles
recordset. Review the steps on the previous
page if you are unsure how to set URL parameters.
Similarly, link the dynamic text to the article.php page, and pass it the URL parameter
id_art
,
which takes the value of the field id_art
.
Figure 18 shows how the index.php page looks when you preview it in the browser window.
Tip: To quickly preview a page from Dreamweaver in your default Internet browser, press F12.
(+) View larger
|