function wikitools_wikilink_drupal_path in Wikitools 6.2
Same name and namespace in other branches
- 5 wikitools.module \wikitools_wikilink_drupal_path()
- 6 wikitools.module \wikitools_wikilink_drupal_path()
- 7 wikitools.module \wikitools_wikilink_drupal_path()
Build a Drupal path to link to a page.
Parameters
$title: title to link to
$query: an optional query string to append to the link
1 call to wikitools_wikilink_drupal_path()
- wikitools_wikilink_url in ./
wikitools.module - Build an url to link to a page.
File
- ./
wikitools.module, line 350 - A non-intrusive module to have some wiki-like behaviour.
Code
function wikitools_wikilink_drupal_path($title) {
if ($wiki_path = wikitools_wiki_path()) {
return $wiki_path . '/' . wikitools_encode_page_name($title);
}
elseif (wikitools_hijack_freelinking()) {
return 'freelinking/' . wikitools_encode_page_name($title);
}
else {
// Neither wikitools nor freelinking will handle the link.
// Try to find a node with the given name and link directly to the first match.
$result = db_query("SELECT nid, type FROM {node} WHERE LOWER(title) = LOWER('%s')", $title);
$found_nodes = array();
while ($node = db_fetch_object($result)) {
if (wikitools_type_affected($node->type)) {
return "node/{$node->nid}";
}
}
}
}