We have an environment which means that a lot of pages have the exact same name. What we need is a way to differenciate that using taxonomies. You already have link filter for the link. is it possible to somehow use the link alias filter when trying to search for the page as well? I hope this makes sense.

Comments

anrikun’s picture

Could you please provide a more concrete example? Thanks!

MoSaG’s picture

Hi omaster,

I have the same problem (same name in different menus).

Here is my solution, until the developer have a better one ;)

on ckeditor_link.module delete or comment out line 46 (starts with: $matches[$node ... )
and replace it with:
$result_content = db_query("SELECT body FROM {node_revisions} WHERE nid = '".$node->nid."' LIMIT 1");
$out=$result_content->fetch_assoc();
$matches[$node->title .' (node/'. $node->nid. ')'] = '

'. check_plain($node->title).' ('.substr(strip_tags($out[body]),0,20) .'...)

';

It gets the first (unformatted) 20 chars of the body text of the node and show it after the title, like:

"title of the node (bodytext of the node ...)"

Dirty little hack, I'm sure there is a better way to do it with drupal api, but for the moment that helps me out, perhaps it's a quick solution for you too.

(sorry for my english ;))

cvbuelow’s picture

Thanks for the tip MoSaG. I found it more useful to append the node url alias to the title:

/* starting at line 39 in ckeditor_link.module */
function ckeditor_link_autocomplete($string = '') {
  $matches = array();

  if ($string !== '') {
    $sql = db_rewrite_sql("SELECT n.nid, n.title FROM {node} n WHERE n.title LIKE '%%%s%%' ORDER BY n.title, n.type");
    $result = db_query_range($sql, array($string), 0, 10);
    while ($node = db_fetch_object($result)) {
	  $out = db_fetch_array(db_query("SELECT dst FROM {url_alias} WHERE src = 'node/".$node->nid."' LIMIT 1"));
	  if(!empty($out["dst"]))
	  {
	  	$parts = explode("/", $out["dst"]);
		array_pop($parts);
	  	$out["dst"] = implode("/", $parts);
	  }
	  $matches[$node->title .' (node/'. $node->nid. ')'] = '<div class="reference-autocomplete">'. $out["dst"] . "/" . check_plain($node->title) .'</div>';
    }
  }

  drupal_json($matches);
}
devin carlson’s picture

Status: Active » Closed (duplicate)

This is a duplicate of #1530862: More verbose autocomplete.