Custom Status Pages
pre {overflow:auto; border:solid 1px #9AACAE; background:#EFEFEF; margin:5px; padding:5px;}
Creating a custom status page for the Drupal Writeup input filter
- The Writeup input filter now contains an api function
writeup_status($ssql)
which may be called from any page that has the php input filter turned on. - To emulate the built in
writeup_status page
, create a new page with the php input format and use this code. It will list all body fields that use the Writeup filter:
<?php $sql = "SELECT n.nid, t.name AS format, r.format AS format_id, r.title, r.body FROM {node} n JOIN {node_revisions} r on r.vid = n.vid JOIN {filters} f on f.format = r.format JOIN {filter_formats} t on t.format = r.format WHERE f.module='writeup' ORDER BY t.name, r.title"; print writeup_status($sql); ?>
- If you want to show a particular CCK field (other than body), use something like this (example taken from crazykoreancooking.com):
<?php $type="recipe"; $field="step"; $sql = "SELECT n.nid, t.name AS format, f.format AS format_id, n.title, r.field_" . $field . "_value FROM {node} n JOIN {content_type_" . $type . "} r on r.vid = n.vid JOIN {filters} f on f.format = r.field_" . $field . "_format JOIN {filter_formats} t on t.format = r.field_" . $field . "_format WHERE f.module='writeup' ORDER BY t.name, n.title"; print writeup_status($sql); ?>
- Two fields can be combined into one using a
UNION
statement. The twoSELECT
s have to be in parenthesis for the finalORDER
to apply to both of them:
<?php $type="ingredient"; $field="ingr_prep"; $sql1 = "(SELECT n.nid, t.name AS format, f.format AS format_id, n.title, r.field_" . $field . "_value FROM {node} n JOIN {content_type_" . $type . "} r on r.vid = n.vid JOIN {filters} f on f.format = r.field_" . $field . "_format JOIN {filter_formats} t on t.format = r.field_" . $field . "_format WHERE f.module='writeup')"; $field="ingr_nutrition"; $sql2 = "(SELECT n.nid, t.name AS format, f.format AS format_id, n.title, r.field_" . $field . "_value FROM {node} n JOIN {content_type_" . $type . "} r on r.vid = n.vid JOIN {filters} f on f.format = r.field_" . $field . "_format JOIN {filter_formats} t on t.format = r.field_" . $field . "_format WHERE f.module='writeup')"; print writeup_status($sql1 . " UNION " . $sql2 . " ORDER BY title, format" ); ?>
- This code will show comments. Bear in mind that the link will be to the whole node, but the title will be the subject of the comment, so multiple comments on one node may be distinguished.
<?php $sql = "SELECT n.nid, t.name AS format, c.format AS format_id, c.subject AS title, c.comment AS body FROM {node} n JOIN {comments} c on c.nid = n.nid JOIN {filters} f on f.format = c.format JOIN {filter_formats} t on t.format = c.format WHERE f.module='writeup' ORDER BY t.name, c.subject"; print writeup_status($sql); ?>