Hi, I'm trying to get a very small module running - I have a menu callback which generates a blank page on activating the callback. I'm basing this heavily on the onthisdate exemplar module on the drupal.org I point my browser at ?q=list_creative/T and receive an empty page. Can anyone advise me on what I'm doing wrong? Apologies if this should have been posted to support instead of development. Cheers Chris There is content in the database matching the T (see below). Here is the (tiny) module: <?php /* $Id$ */ /** * Display help and module information * @param section which section of the site we're displaying help * @return help text for section */ function rockstanza_help($section='') { $output = ''; switch ($section) { case "admin/help#rockstanza": $output = '<p>'. t("Manages blocks for accessing creative and excursion posts on RockStanza website") . '</p>'; break; } return $output; } //function rockstanza_help /** * Valid permissions for this module * @return array An array of valid permissions for the rockstanza module */ function rockstanza_perm() { return array('access rockstanza content'); } //function rockstanza_perm /** * Implementation of hook_menu(). */ function rockstanza_menu() { $items = array(); $items[] = array( 'path' => 'list_creative', 'title' => t('Creative works'), 'callback' => 'rockstanza_list_creative', 'access' => user_access('access rockstanza content'), 'type' => MENU_CALLBACK ); return $items; } /** * Generate HTML for the rockstanza block * @param op the operation from the URL * @param delta offset * @returns block HTML */ function rockstanza_block($op='list', $delta=0) { switch ($op) { case "list": //listing of blocks, eg. on admin/block page $block[0]["info"] = t("RockStanza Creative"); break; case "view": $block['subject'] = t('Creative works'); $block['content'] = ''; $first_letter_list = ""; //this will be a list of the first letter of broch names $result = db_query("SELECT title FROM {node} " . "WHERE {node}.{type} = 'poem' ORDER BY {title} ASC"); $index = array(); do { $t = db_fetch_array($result); $letter=$t['title'][0]; $index[$letter]=$letter; //store unique first letters in list } while ($t); $letterlist = implode ('',$index); //store in variables table foreach ($index as $fl) { $block['content'] .= l($fl,"list_creative/$fl", array('title' => "Creative works beginning $fl", 'target' => '_self'), NULL, NULL, FALSE, FALSE) . ' '; } break; } return $block; } //function rockstanza_block /** Group creative posts (e.g. poems) by the first letter of their title * use via menu callback * @returns content HTML */ function rockstanza_list_creative($firstletter) { $fl = '^'.$firstletter[0]; //get all poems with chosen first letter of title $result = db_query(db_rewrite_sql( "SELECT n.nid, n.title, n.type " . "FROM {node} n " . "WHERE n.type = 'poem' " . "AND n.title REGEXP '%s' " . "ORDER BY n.title ASC", $fl )); //leave only the node titles in the results $content = node_title_list($result); }
On Wednesday 11 July 2007 23:24, Chris McGinlay wrote: Sorry! Fixed this myself - I had not set any output to be displayed. Thanks anyway Chris
Add print theme('page',$content); at the end of your rockstanza_list_creative() function.
Hi,
I'm trying to get a very small module running - I have a menu callback which generates a blank page on activating the callback. I'm basing this heavily on the onthisdate exemplar module on the drupal.org
I point my browser at ?q=list_creative/T and receive an empty page. Can anyone advise me on what I'm doing wrong? Apologies if this should have been posted to support instead of development.
Cheers
Chris /** Group creative posts (e.g. poems) by the first letter of their title * use via menu callback * @returns content HTML */ function rockstanza_list_creative($firstletter) { $fl = '^'.$firstletter[0];
//get all poems with chosen first letter of title $result = db_query(db_rewrite_sql( "SELECT n.nid, n.title, n.type " . "FROM {node} n " . "WHERE n.type = 'poem' " . "AND n.title REGEXP '%s' " . "ORDER BY n.title ASC", $fl ));
//leave only the node titles in the results $content = node_title_list($result); }
-- Ramiro Gómez Software developer with focus on content management systems, SEO, and open source. Websites: www.ramiro.org www.seo-expert-blog.com www.torlaune.de
On Thursday 12 July 2007 03:35, Rob Barreca wrote:
Ramiro Gómez wrote:
Add
print theme('page',$content);
at the end of your rockstanza_list_creative() function.
Actually, you can just return $content; and it will get wrapped in theme('page') automatically.
-Rob Thanks, returning $content is a neat and tidy solution and works fine.
Chris
participants (3)
-
Chris McGinlay -
Ramiro Gómez -
Rob Barreca