Building a Forum with Dreamweaver – Part 2: Hiding Content with Conditional Regions
Hiding Content with Conditional Regions
To control what links are displayed when users are logged in and what to display when they are not, you will use a conditional region added by ImpAKT: Show If User Is Logged In. You can access it from the Server Behaviors tab by selecting Plus (+) > MX Kollection > Conditional Regions.
Follow these steps to display the logout link for logged-in users and the others for the rest:
- Open the index.php page.
- Select the Logout link in the top-right corner.
-
Apply the Show If User Is Logged In server behavior. Configure the dialog box as shown in Figure 28:
- For the restriction type, select the Username and Password option.
-
Check the Has ELSE option. Text in the ELSE region will be displayed if the condition is not met (the user is not logged in).
-
Click OK to apply the server behavior. In Dreamweaver, a gray border appears around the Logout link, along with some placeholder text (
Else text: Replace this
), as shown in Figure 29. - Select the
Register | Login
text and cut it from the page. - Select the placeholder text (
Else text: Replace this
) and remove it. Then paste the Register and Login links from the Clipboard. -
Save the page and preview it in a browser. Because you are not logged in, the register and login links will appear as shown in Figure 30.
Try to log in using one of the sample user accounts. Notice that only the Logout link is visible. Repeat the previous steps for the view_message.php, post_message.php, and reply_message.php pages.
That’s it! You have successfully built a user authentication system for your forum. In Part 3 of this tutorial, you will build forms for posting new messages and replies.
Comments