Link to content on this site using [title|text].', array("%title-help" => url('filter/tips', NULL, 'filter-title'))); case 'filter#long-tip' : return '
' . t('You may quickly link to content on the site using this syntax: [title|text]. This will generate a link labeled "text" to the content with the title "title". If you omit "|text", the label becomes "title".') . '
'; } } /** * Implementation of hook_menu(). */ function title_menu() { $items = array(); $items[] = array('path' => 'title', 'title' => t('search'), 'callback' => 'title_page', 'access' => user_access('access content'), 'type' => MENU_CALLBACK); return $items; } /** * Menu callback; displays the matching node or a list of search results. */ function title_page($query) { $title = urldecode($query); $result = db_query("SELECT n.*, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.title = '%s' AND n.status = 1 ORDER BY n.created DESC", $title); $title = trim(str_replace(array('_', '%', '*'), ' ', $title)); if (db_num_rows($result) == 0) { // No node with exact title found; try a substring. $result = db_query("SELECT n.*, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.title LIKE '%%%s%%' AND n.status = 1 ORDER BY n.created DESC", $title); } if (db_num_rows($result) == 0 && module_exist('search')) { // Still no matches, so return a full-text search. search_view($title); } else if (db_num_rows($result) == 1) { $node = db_fetch_object($result); $node = node_load(array('nid' => $node->nid)); print theme('page', node_show($node, NULL), $node->title); } else { $header = array(t('Type'), t('Title'), t('Author')); while ($node = db_fetch_object($result)) { $type = ucfirst(module_invoke($node->type, 'node', 'name')); $title = l($node->title, "node/$node->nid"); $author = format_name($node); $rows[] = array(array('data' => $type, 'class' => 'type'), array('data' => $title, 'class' => 'content'), array('data' => $author, 'class' => 'author')); } $output = '