Closed (fixed)
Project:
Linkit
Version:
6.x-1.4
Component:
Miscellaneous
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
14 Jul 2010 at 20:39 UTC
Updated:
3 Aug 2010 at 23:10 UTC
Anyone interested in finding path/url aliases with this module? To me this seemed like a relevant use case, so thanks to the very nice design for extending the module with plugins, I quickly modified the linkit_views plugin to create a plugin module to find aliases. Of course, you would want to limit access to this functionality to a trusted role as it exposes all url aliases.
Posting the module's code for feedback and the potential interest of others:
/**
* Implementation of hook_linkit_load_plugins().
*/
function linkit_alias_linkit_load_plugins($string) {
$matches = array();
$result = db_query_range("SELECT * FROM {url_alias} WHERE LOWER(dst) LIKE LOWER('%%%s%%') ORDER BY length(dst) ASC", $string, 0, 10);
while ($alias = db_fetch_object($result)) {
$matches['alias'][] = array(
'title' => $alias->dst,
'path' => base_path() . $alias->src,
'information' => array(
'type' => 'Alias',
),
);
}
return $matches;
}
/**
* Implementation of hook_linkit_info_plugins().
*
* This is used by linkit_permissions
*/
function linkit_alias_linkit_info_plugins() {
$return['linkit_alias'] = array(
'type' => 'alias',
);
return $return;
}
Comments
Comment #1
anonNice, feel free to make your own module of this code as an "plugin'" to linkit.
I can link to it from the linkit project page if you like.
Comment #2
anon