| 1 |
Comment Page
|
| 2 |
By: Ryan
|
| 3 |
------------
|
| 4 |
|
| 5 |
This module was developed to increase the number of pages on a site that can be
|
| 6 |
indexed by search engines. It accomplishes this by creating pages that display
|
| 7 |
comments individually along with an optional thread review that links to other
|
| 8 |
comments in a thread display. The individual pages will also come in handy for
|
| 9 |
your site's users, as it makes for easy bookmarking and linking to particular
|
| 10 |
comments in a discussion. This module was particularly designed with site
|
| 11 |
forums in mind.
|
| 12 |
|
| 13 |
Pages use a very simple URL naming scheme: 'comment/1'
|
| 14 |
|
| 15 |
The comment subject is also included after the comment ID to include search
|
| 16 |
keywords in the URL. (This is among the optional display settings and requires
|
| 17 |
that you have Pathauto enabled to work.)
|
| 18 |
|
| 19 |
The link to the page may be displayed in the normal comment links section, or
|
| 20 |
that link may be turned off and you can include the link somewhere else by
|
| 21 |
theming. An example of integrating this module with Flatforum is below.
|
| 22 |
|
| 23 |
View all the display options at 'admin/content/comment_page'.
|
| 24 |
|
| 25 |
You can also set your site's comments to default their subjects to something
|
| 26 |
like "Re: Parent subject" when the comment subject field is left blank.
|
| 27 |
|
| 28 |
Module developed sponsored by the Ubercart project. (http://www.ubercart.org)
|
| 29 |
|
| 30 |
To see this in action, check out our forums! (http://www.ubercart.org/forum)
|
| 31 |
|
| 32 |
------------
|
| 33 |
|
| 34 |
Theming the comment link using Flatforum:
|
| 35 |
|
| 36 |
With comment page, it is possible to modify the Flatforum code added to your
|
| 37 |
theme's template.php to see if the parent node is a forum node. This will tell
|
| 38 |
the theme to present the comment page like a forum post.
|
| 39 |
|
| 40 |
This code should be modified to look something like this:
|
| 41 |
|
| 42 |
static $is_forum;
|
| 43 |
$variables = array();
|
| 44 |
if (!isset($is_forum)) {
|
| 45 |
if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == '') {
|
| 46 |
$nid = arg(1);
|
| 47 |
}
|
| 48 |
if (arg(0) == 'comment' && arg(1) == 'reply' && is_numeric(arg(2))) {
|
| 49 |
$nid = arg(2);
|
| 50 |
}
|
| 51 |
// Added for Comment Page.
|
| 52 |
if (arg(0) == 'comment' && is_numeric(arg(1))) {
|
| 53 |
$nid = $vars['comment']->nid;
|
| 54 |
}
|
| 55 |
if ($nid) {
|
| 56 |
$node = node_load(array('nid' => $nid));
|
| 57 |
}
|
| 58 |
$is_forum = ($node && $node->type == 'forum');
|
| 59 |
_is_forum($is_forum);
|
| 60 |
}
|
| 61 |
|
| 62 |
This will ensure a forum comment gets themed like your forum posts. You can
|
| 63 |
also make a link available for us in your template files. Comment Page adds a
|
| 64 |
field called page_url to the comment object when it is being viewed. You can
|
| 65 |
expose this to the template by including it in your $vars or $variables array,
|
| 66 |
whichever you have set to be returned by template.php in the function
|
| 67 |
_phptemplate_variables().
|
| 68 |
|
| 69 |
In the if block executed for forum themed posts is a switch that has a case for
|
| 70 |
comments. You can add something like the following to be able to use a variable
|
| 71 |
named $page_url in your template file as a link to the comment page:
|
| 72 |
|
| 73 |
$variables['page_link'] = l('view page', $vars['comment']->page_url);
|
| 74 |
|
| 75 |
To make it so this variable isn't set on the comment page itself, you'd want to
|
| 76 |
use something a little more involved like the following:
|
| 77 |
|
| 78 |
if (!(arg(0) == 'comment' && arg(1) == $vars['comment']->cid)) {
|
| 79 |
$variables['page_link'] = l('view page', $vars['comment']->page_url);
|
| 80 |
}
|
| 81 |
|