Use [#nid] filter output for "Recent issues" block

dww - May 5, 2009 - 23:33
Project:Project issue tracking
Version:6.x-1.x-dev
Component:Views integration
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

I just had a slick idea to make the new #22402: Recent issues block on project nodes more useful. However, I don't know how to best implement it. ;)

Basically, instead of just outputting the title as a link, it'd be slick if it could output [#nid] and let the issue filter do all the fancy stuff it already does (color coding, strike-through, mouse-over, etc). Knowing it wasn't going to work, I tried the new "rewrite the output of this field" stuff, and of course, I just ended up with [#nid] not the desired filter output. ;)

I suppose I could write another custom field handler for issue titles to do this, but that seems a little lame.

Hopefully I can strategize with Earl about this and figure out a reasonable way to solve this...

#1

merlinofchaos - May 5, 2009 - 23:42

I suppose I could implement some kind of a hook to allow you to add filtering to the field output.

#2

sun - December 10, 2009 - 18:12

Auto-generating text and invoking the filter system on it doesn't sound like a good idea.

Instead, I'd suggest to make the filter simply expose a public, re-usable function.

The regular, current input is

[#nid]

and the filter process callback is

<?php
function project_issue_filter_process($text) { // Sorry, D6 is soo old ;)
 
preg_match_all('...', $text, $matches);
  foreach (
$matches as $match) {
   
$replace[$match[0]] = project_issue_filter_convert($match[1], $match[2]);
  }
  ...
  return
$text;
}
?>

so the filter's process helper callback takes

<?php
function project_issue_filter_convert($nid, $comment = NULL) {
 
$output = ...
  return
$output;
}
?>

Hence, you can do a Views field handler that takes the 'nid' (actually, an arbitrary nid), passes it through the helper, and returns the result.

 
 

Drupal is a registered trademark of Dries Buytaert.