Table of Contents

Chapter 4 - adding pages to the website

Including pages in the website is almost the same as including pages in plucks administration center. First, we'll explain how you can define the inclusion page of your module.

Defining the inclusion page

When a user includes your module in (a page of) his website, pluck needs to know which file must be included in the page. We inform pluck about this by using the variable $includepage.

For including pages in the administration center of pluck, we used a file called module_pages_admin.php (see chapter 3). For including pages in the website, we have a similar file, called module_pages_site.php. The pages we'll put in the directory pages_site, located in the module-directory. In the case of our poll module, this will be data/modules/polls/pages_site/.

Now, if the filename of the inclusion page is show_poll.php, we can put the following in module_pages_site.php:

<?php
$includepage = "show_poll.php";
?>

Now, pluck knows how to include your module into pages of the website.

Adding more pages

Ok, now we pluck can show our poll module in a page. However, some modules may want to include more pages in the website: for our poll module for example, we want a page on which the visitor can see all old (archived) polls. How can we achieve that?

Adding the page

Adding additional pages works exactly the same for the website as for the administration center. Read how to add a page here.

In the case of our poll module (where we want to include the file show_archived.php), this will be the resulting code:

$module_page['show_archived'] = "show archived polls";

Linking to the page

We have now included the page to show the archived polls, but we still want to link to that page so the user can easily find the page. How do we know the exact URL to the page?

The URL for a module-page on the website looks almost the same as the URL for a page in the administration center:

?module=module_dir&page=filename_without_extension

So, the entire URL to access our "new poll"-page is:

?module=polls&page=show_archived

We can link to the page like this:

<a href="?module=polls&page=show archived">show archived polls</a>

Resulting code

After implementing a few more pages, this could be an example of the resulting code in module_pages_site:

<?php
$includepage = "show_poll.php";
$module_page['show_archived'] = "show archived polls";
$module_page['vote'] = "submit vote";
$module_page['show_period'] = "show polls from time period";
?>

Ok, let's go to the next chapter!

Let's go to the next chapter and learn more about other possibilities of the pluck module system! Go to the next chapter...