Table of Contents

If you only have one comments page, e.g. a guestbook, this is of no interest to you. It is intended for sites that have multiple pages on which there are comments. This addon creates a list of the n most recent comments from all of your comments pages. screen capture

The scripts are in /addons/recent-comments. Upload the three scripts to your TalkBack directory. Browse to yoursite.com/talkback/comments/recent-comments.php and you should see a list of your recent comments.

You can then customize the styles and template to fit your site layout.

recent-comments.php

An example recent comments page. It is a mockup of the page that would be the target of your link to recent comments. Edit it to add your page heading, sidebars, etc.

Include the TalkBack stylesheet links in your page just like you did for your guestbook/comments pages. You need to add two new styles, .tb-page-legend and .tb-page-url, which can be in a <style> tag in the <head> section or you may want to add them to the TalkBack style sheet.

If you want the styles on the recent comments page to be different than the styles on the original comments page, you can override the stylesheet styles by putting them in a <style> tag in your recent-comments.php page.

recent.php

Selects, formats and prints the comments. You may want to edit the configuration variables at the beginning of the script. But don’t change anything below thoes unless you are experienced with PHP.

$num_comments   = 15;                   // Number of comments to select
$page_legend    = 'Comments on page:';  // precedes page url on the list, e.g. Comments on page: /guestbook.php
$subject_title  = 'Subject:';           // precedes the comment subject
$groupby_page   = 'N';                  // Y = list is sorted by page ascending, date descending
                                        // N = list is sorted by date descending
$show_link      = 0;                    // 1 = always show the page link
                                        // 0 = only if it is different from the comment above

// Convert page URL's to a page name
$conv_table =      array(
                  );

// Exclude comments on specified pages
$exclude_page =   array(
                     '/talkback/test.php',
                  );

// Exclude comments on all pages in specified directories
$exclude_dir =      array(
                  );
                  
/* +++++++++++++++++++++++++++++ Examples +++++++++++++++++++++++++++++
$conv_table =      array(
                     '/guestbook.php'      => 'Guestbook',
                     '/dir1/comments.php'  => 'Some name',
                     '/dir2/index.php'     => 'Another name',
                  );

$exclude_dir =      array(
                     '/dir1/',
                     '/dir1/dir1/',
                  );
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/

$num_comments is the maximum number of comments that will be listed.

$page_legend will be placed in front of the page name or URL.

$subject_title will be placed before the subject field if you are using the subject field.

$groupby_page If set to 1, the list will be sorted by page URL ascending / date/time descending. If set to 0, it is sorted by date/time descending.

$show_page If set to 1, the page link will always be shown. If set to 0, it is shown only if it is different from the comment above it.

Entries in $conv_table cause the comment page URL to be replaced with a name of your choice.

Comments for page URL’s in $exclude_page will not appear in the listing.

Comments on all pages for directories specified in $exclude_dir will not appear in the listing.

recent-tpl.php

This is the comments template. Look familiar? It should. It is essentially the same as in comments-display-tpl.php. You can rearrange the layout, change class names, etc.