DrupalBin
Submit Code
About
Recent Posts
Code
Why won't this work?
Code
Code
radioactivity flags
Fix for Fix for term description to display as a sub-page title for each different termid (argument)
array_splice??
Fix for term description to display as a sub-page title for each differnet termid (argument)
Code
Fix for Hide page titles for certain node types in page.tpl.php
more
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Log in using OpenID
Cancel OpenID login
Create new account
Request new password
Tags
CCK
drupal
fapi
jquery
menu
module
Panels
simpletest
test
theme
user
views
more tags
Home
Fix for Post for g.d.o
View
Fix
September 10, 2009 - 3:08pm — Anonymous
It's been a <em>long</em> time since I wrote this and I haven't revisited it to see if it could be made better with all I've learned since then. So hopefully it's not too cringeworthy. :)
(in preprocess_comment)
<?php
if
(
!
isset
(
$post_number
)
)
{
static
$post_number
=
0
;
}
_advanced_forum_topic_nid
(
$variables
[
'node'
]
-
>
nid
)
;
$post_per_page
=
_comment_get_display_setting
(
'comments_per_page'
,
$variables
[
'node'
]
)
;
$page_number
=
!
empty
(
$_GET
[
'page'
]
)
?
$_GET
[
'page'
]
:
0
;
if
(
!
$page_number
)
{
$page_number
=
0
;
}
$post_number
++;
$fragment
=
'comment-'
.
$variables
[
'comment'
]
-
>
cid
;
$query
=
(
$page_number
)
?
'page='
.
$page_number
:
NULL
;
$linktext
=
'#'
.
(
(
$page_number
*
$post_per_page
)
+
$post_number
)
;
$linkpath
=
'node/'
. _advanced_forum_topic_nid
(
)
;
$variables
[
'comment_link'
]
=
l
(
$linktext
,
$linkpath
,
array
(
'query'
=
>
$query
,
'fragment'
=
>
$fragment
)
)
;;
?>
<?php
/**
* Holds the node ID of the thread we are on.
*
* Used for linking the comment numbers.
*
* @param $nid
* Node ID
*/
function
_advanced_forum_topic_nid
(
$node_id
= 0
)
{
static
$nid
;
if
(
!
empty
(
$node_id
)
)
{
$nid
=
$node_id
;
}
return
$nid
;
}
?>
Don't ask me why I have a function to hold the NID... I haven't the foggiest idea.
Michelle
Submit Fix
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Show summary in full view
It's been a <em>long</em> time since I wrote this and I haven't revisited it to see if it could be made better with all I've learned since then. So hopefully it's not too cringeworthy. :) (in preprocess_comment) <?php if (!isset($post_number)) { static $post_number = 0; } _advanced_forum_topic_nid($variables['node']->nid); $post_per_page = _comment_get_display_setting('comments_per_page', $variables['node']); $page_number = !empty($_GET['page']) ? $_GET['page'] : 0; if (!$page_number) { $page_number = 0; } $post_number++; $fragment = 'comment-' . $variables['comment']->cid; $query = ($page_number) ? 'page=' . $page_number : NULL; $linktext = '#' . (($page_number * $post_per_page) + $post_number); $linkpath = 'node/' . _advanced_forum_topic_nid(); $variables['comment_link'] = l($linktext, $linkpath, array('query' => $query, 'fragment' => $fragment));; ?> <?php /** * Holds the node ID of the thread we are on. * * Used for linking the comment numbers. * * @param $nid * Node ID */ function _advanced_forum_topic_nid($node_id = 0) { static $nid; if (!empty($node_id)) { $nid = $node_id; } return $nid; } ?> Don't ask me why I have a function to hold the NID... I haven't the foggiest idea. Michelle
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal 5
Drupal 6
HTML
INI
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.
See Also:
Order
Title:
URL:
-1
0
1
Title:
URL:
-1
0
1
Any links you'd like to have associated with the post (Drupal.org issue, Wikipedia article, etc).
File attachments
Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.
Attach new file:
The maximum upload size is
1 MB
. Only files with the following extensions may be uploaded:
jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp
.