The attached add-on files may be out of date. Please visit Devot-ee for the latest versions.
This plugin allows you to find the page containing certain comment and redirect to that page. Supports pagination. Can be used together with extension which scroll to the last comment but does not support pagination, such as Matthew Pennell’s Scroll to the last comment extension.
Also it can be used to support linking directly to comments, for example when someone wants to link to certain article’s comment having absolute count 48 and which is on second page out of five comment pages, he will be able to use such link as
http://mysite.com/index.php/template_group/template/url_title/#comment_511/and plugin will redirect to the page which contains needed comment.
PARAMETERS
1) per_page - Required. Allows you to specify how many comments are displayed on the page. The value of this parameter MUST BE the same as the value of “limit” parameter of exp:comment:entries tag.
2) prefix - Optional. Allows you to specify the prefix used in URL segment to identify certain comment.
3) comment_id - Optional. Allows you to specify comment_id of certain comment.
Either “prefix” or “comment_id” parameter must be defined.
4) sort - Optional. Allows you to specify how comments are sorted. The value of this parameter MUST BE the same as the value of “sort” parameter of exp:comment:entries tag. Possible values are “asc” and “desc”. Default is “desc”.
5) orderby - Optional. Allows you to specify how comments are ordered. The value of this parameter MUST BE the same as the value of “orderby” parameter of exp:comment:entries tag. Default value is “date”. Parameter accepts the same values as “orderby” parameter of exp:comment:entries tag.
VARIABLES
1) c_location_current_pagination_number - outputs pagination number of currently opened page (i.e. of the page before redirect is performed). In case the page has no pagination segments, its pagination number is “0”.
2) c_location_pagination_number - outputs pagination number of the page in which needed comment is present. In case the page has no pagination segments, its pagination number is “0”.
3) c_location_comment_id - id number of the needed comment.
4) c_location_entry_id - entry id of the entry needed comment is posted to.
5) c_location_weblog_short_name - weblog short name of the entry needed comment is posted to.
6) c_location_total_comments - total number of comments posted into entry.
7) c_location_absolute_count - absolute count number of the needed comment including comments on previous pages (if using pagination).
8) c_location_count - count number of the needed comment on the page needed comment is displayed. If five comments are being displayed per page, then for the fourth entry on the page the {c_location_count} variable would have a value of “4”.
9) c_location_current_page - number of page in which needed comment is displayed.
10) c_location_total_pages - total number of comment pages.
11) c_location_pagination_segment - outputs pagination segment of the page in which needed comment is located. E.g. if pagination segment is “P50” then this variable will output “P50/”. If there is no pagination, then this variable will output an empty string.
12) site_url - outputs the same as ExpressionEngine’s “site_url” variable.
13) homepage - outputs the same as ExpressionEngine’s “homepage” variable.
14) c_location_redirect - has required parameter “location”. Redirects to location which is specifies as the value of this parameter. This variable is parsed after any other variable of this plugin. That means that any variable can be used inside parameter.
EXAMPLE OF USAGE
On top (i.e. before any other code) of the template in which there is exp:comment:entries tag place the code as this:
{exp:c_location per_page="30" prefix="#comment_" sort="asc"}
{if c_location_comment_id != "" AND c_location_pagination_number != c_location_current_pagination_number}
{c_location_redirect location="{homepage}/{segment_1}/{segment_2}/{segment_3}/{c_location_pagination_segment}#comment_{c_location_comment_id}/"}
{/if}
{/exp:c_location}OK, I’m confused. Right now my recent comments list works this way:
And this plugin seems to have no effect. Do I need to change the variable used for the url_title_path?
Right now, the list is designed to link directly to a comment on the full story page and it works as long as the comments aren’t paginated. (Actually, the stories can’t be paginated, either.)
I was hoping the plug-in would allow me to paginate stories that have scores of comments. But, it’s still only working it the comment is within the first 10 (or whatever variable I set). So I’m thinking that I’m not forming the link in a way that the plugin expects?
Thoughts?
This plugin does not paginate anything. It finds certain comment inside paginated comment entries.
I understand that, however it’s not working for me. My question is, does it expect the link to that comment to be structured in a way that’s different from the link I pasted above? Thanks!
Here’s the c_location tag pair:
{exp:c_location per_page="10" prefix="#c" sort="asc"}
{if c_location_comment_id != "" AND c_location_pagination_number != c_location_current_pagination_number}
{c_location_redirect location="{homepage}/{segment_1}/{segment_2}/{segment_3}/{c_location_pagination_segment}#c{c_location_comment_id}/"}
{/if}
{/exp:c_location}And here’s what I’m using to link to recent comments from my site’s home page (www.jacksonfreepress.com):
And here’s the comment code from the comments page template:
Thanks!
Hi,
It seems that you do not consistently use “sort” parameter. The value of this parameter of exp:c_location tag MUST BE the same as the value of “sort” parameter of exp:comment:entries tag. But the exp:comment:entries tag in your comments page template does not have this parameter (default value is “desc”).
So, your c_location tag pair has “asc” as the value of “sort” parameter, but exp:comment:entries tag in your comments page template has “desc” as the value of “sort” parameter.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.