Showcase and discover digital art at yex

Follow Design Stacks

Subscribe to our free newsletter to get all our latest tutorials and articles delivered directly to your inbox!

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:

  1. Open the index.php page.
  2. Select the Logout link in the top-right corner.
  3. Apply the Show If User Is Logged In server behavior. Configure the dialog box as shown in Figure 28:

    1. For the restriction type, select the Username and Password option.
    2. 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).

    Configuring the Show If User Is Logged In server behavior

    Figure 28. Configuring the Show If User Is Logged In server behavior

  4. 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.

    Conditional region placeholder

    Figure 29. Conditional region placeholder

  5. Select the Register | Login text and cut it from the page.
  6. Select the placeholder text (Else text: Replace this) and remove it. Then paste the Register and Login links from the Clipboard.
  7. 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.

    Conditional display of links

    Figure 30. Conditional display of links

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