Redesign the gallery with MX Includes

The current organization of the gallery files does not allow simple navigation through all of the albums and pictures. That is why in this tutorial topic you will enhance the gallery, by putting all the elements that make up the gallery in a single page. You will reuse the pages created so far, using MX Includes, which allows placing existing files within a single page in a static or dynamic way.

On the gallery home page (index.php), you will place the following elements:

MX Includes is a tool that allows easy code-reuse, incorporating already made pages into others, in a static or dynamic manner. To learn more about this product, please see Reuse content: Server-Side Includes.

 

Before actually creating the main page, you must decide what files will be used, and if they require any modifications:

 

The menu file requires some modifications, as all of its links point to the album.php page.

Next you have to modify the menu to be displayed in the home page. To do so, follow the next steps:

  1. Open the menu.php file in Dreamweaver.

  2. Link each album title to the index.php page, because the menu, as well as the images will be displayed there. The links must also pass the id_alb URL parameter, as well as a static parameter, which will be used to determine which page to load in the index file: Set its name to mod, and its value to album.


     

  3. If needed, trim the table rows and columns so that the browser view will appear like the image below. Save the file and close it. The browser preview will simply display a set of links:

 

The next file to be changed is default.php:

  1. Open the default.php file in Dreamweaver.

  2. Select the show thumbnail translator in the Horizontal Looper. This is the one used to display the latest 5 additions.

  3. Change its link, so that it will point to the index.php page. Leave the id_img parameter in place, and also add another: name: mod, value: detail, similar to the image above.

  4. Save the page and close it for now.

 

It is time to begin creating the site's new main page. To do so, follow the instructions below:

  1. Open the index file in Dreamweaver.

  2. Add a new table containing 2 rows and 2 columns. Set the border to 0.

  3. Click in the second row's first column. This is where the menu will be displayed.

  4. Apply the Server-Side Include server behavior from Server Behaviors -> + -> MX Kollection -> MX Includes.

  5. Use the Browse button to select the menu file and click the OK button to close the dialog box. Now the menu will appear on page.


     

  6. Click in the second row's second cell. This is where different pages will load, depending on an URL parameter. This parameter will be called mod (from mode).

  7. Apply the Server-Side Includes From List server behavior from Server Behaviors -> + -> MX Kollection -> MX Includes.

  8. To configure the Basic tab, enter the next 3 value/page to load/title groups:
    · URL value: leave empty; Filename: default.php; Title: Welcome to the Image Gallery
    · URL value: album; Filename: album.php; Title : Images in album.
    · URL value: detail; Filename: full_view.php; Title: Image details.


     

  9. To configure the Parameter tab, enter mod in the respective text box:


     

  10. Click OK button to close the dialog box.

  11. Save the page and preview it in the browser. The default page that opens displays the random image, as well as the latest 5 additions.

 

There is still one more tweak before your gallery is ready. When you click on an image to see it full scale, it opens the full_view page, instead of the new home page. This is what you will have to change next: edit the links on the images.

Open the album page in Dreamweaver. You will have to edit the links on images, so that it will open the correct page with the right parameters.
  1. Click on the image placeholder, and edit the link so that it will point to the index file. Leave the id_img parameter, as it is handled by the full_view page, and also add the mod parameter. Set its value to detail, as configured in the Server-Side Includes From List server behavior.
  2. Close the page and save it.
Now, when you click on an image, it will open it at full scale inside the index file, displaying the menu as well:


 
You only have to do one more thing before calling it a wrap: add a link that will take the visitor to the home page. In the index page, click in the first row's first cell, and type Home, or add a logo. Using the Make link dialog box, set it to point to the index file without any kind of parameter.


 
Enjoy the Image gallery you've created, and store as many pictures as you wish in how many albums you have. If you want to further enhance your application, you can add the possibility for users to comment on each image, or even add images of their own, by allowing them to register on your site.