Creating a messages archive page

While the previous section explained how to add functionality to phpList by manual editing of the source code, this section will walk you through implementing a "ready-built" phpList hack—the messages archive page.

Perhaps you want your readers to be able to refer to an "archives" page to be able to find and re-read your previous mailings. phpList itself does not provide such an archive, but some committed users have implemented an effective solution.

The solution is discussed in the phpList forums at http://forums.phplist.com/viewtopic.php?t=1501 and the necessary code is available at http://docs.phplist.com/NewsletterArchive. Copy the contents of the wiki page (everything from the opening<?php tag at the top to the closing ?> tag at the bottom), and paste it into a new file called archive.php at the root of your publicly accessible phpList files.

You'll recall from Chapter 8, Securing phpList, that the .htaccess file in the root of your phpList installation controls which files may be viewed by web users.

Open .htaccess (you may have to enable viewing of hidden files to see it) and look for this line (around line #8):

<FilesMatch "(index.php|dl.php|ut.php|lt.php|download.php)$">

Change this line to include archive.php. The line should now look like this:

<FilesMatch "(index.php|dl.php|ut.php|lt.php|download.php|archive.php)$">

Direct your web browser to http://your-phplist-installation/archive.php—you'll see a list of all your lists. Clicking each one will show you a reverse-chronological list of the messages sent to that list, 20 per page:

Creating a messages archive page

Customizing the number of messages displayed per page

By default, 20 messages will be displayed per page. To change the number of messages per page, add the string "&pagerows=x" to the URL, where x is the number of messages to display.

In the following illustration, the string "&pagerows=2" was added to the URL, so only two messages are displayed per page:

Customizing the number of messages displayed per page

Adding a message summary to the list

If your users are going to be making frequent use of your archives, you may want to include a summary of each message on the list of messages page. You can't do this retrospectively to messages that have already been sent, but you can ensure than any subsequent messages include a summary.

In the send a message window, when you compose your message, enter the summary between the<summary> and</summary> tags:

Adding a message summary to the list

Tip

Adding a summary in HTML source mode

Note that you won't be able to enter the summary tags in the regular WYSIWYG mode. Even if you attempt to do so, the angular brackets will be changed into HTML entities (that is,< becomes&lt;), rendering them invalid. You'll need to switch the message editor into Source mode to add these tags.

Once a message with a summary has been processed, the summary will be displayed on the archive.php page:

Adding a message summary to the list

Hiding the summary in outgoing e-mails

If you don't want the summary text to be displayed in the actual message sent to your readers, encapsulate the summary tags in HTML comment tags. For example, if your hidden summary was to read "Super-subscriber Christmas specials!", you'd enter it as:

<!-- <summary>Super-subscriber Christmas specials!</summary> -->

Linking the archives to the main index

Now that you have automatic message archiving, you may want to allow users to reach the archives via a link on the main page.

To accomplish this, open index.php and look for the following line (around line #274):

printf('<p><a href="./?p=unsubscribe">%s</a></p>',$strUnsubscribeTitle);

Directly below this line, add the following:

// START HACK - Link to archives
if (isset($strArchiveTitle)) {
$TitleArchive = $strArchiveTitle;
} else {
$TitleArchive = "See the archive";
printf("
" . '<p><a href="archive.php">%s</a></p>', $TitleArchive);
}
// END HACK - Link to archives

Now the index page will include a link to the archives page:

Linking the archives to the main index

Tip

Changing the "See the archive" string

If you're using a non-English translation, or if you just want to change the See the archive text, set the variable $strArchive to the text you want to be displayed in the appropriate language file (under the texts subdirectory).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.44.229