In nodereference field of a content type, Is it possible to show the content type name added with the autocomplete results? In nodereference field of a content type, Is it possible to show the content type name added with the autocomplete results ?

Example :

I have a content type named Article which has a node reference field (Related content -> field_related_documents), So that this article will referenced to other nodes.

While creating an article, by entering 'help' in 'field_related_documents' I am getting autocomplete results (titles of referenced nodes) like below

helpsystems - rules
Decision management Help
Using help menu
Help support glossary


Instead, I like to show results like below

Page | helpsystems - rules
HelpSystems | Decision management Help
Page | Using help menu
Document | Help support glossary


ie) autocomplete results should display title of other nodes added with their related content type.

How should i achieve this ?
I created a new custom Module nodereference_patch with below hook

/*
 * Altering nodereference/autocomplete menu using menu alter
 */
function nodereference_patch_menu_alter(&amp;$items) {
  $items['nodereference/autocomplete']['page callback'] = 'nodereference_patch_new_nodereference_autocomplete';
}


Then, I copied the nodereference_autocomplete function into your custom module, changing it's name to nodereference_patch_new_nodereference_autocomplete. 

Then I changed this line:

$matches[$row['title'] ." [nid:$id]"] = '&lt;div class="reference-autocomplete"&gt;'. $row['rendered'] . '&lt;/div&gt;';


to

$matches[$row['type'] . " | " . $row['title'] . " [nid:$id]"] = '&lt;div class="reference-autocomplete"&gt;' . $row['type'] . " | " . $row['rendered'] . '&lt;/div&gt;';


I copied _nodereference_potential_references function from nodereference.module to custom module and renamed it as _nodereference_patch_potential_references

Then I changed the following line as 

$references = _nodereference_potential_references_standard($field, $string, $match, $ids, $limit);


to

$references = _nodereference_patch_potential_references_standard($field, $string, $match, $ids, $limit);


I copied _nodereference_potential_references_standard from nodereference.module to custom module and renamed it as _nodereference_patch_potential_references_standard

Then I added 'type' element to $references[]. ie) changed following array from

$references[$node-&gt;nid] = array(
    'title' =&gt; $node-&gt;node_title,
    'rendered' =&gt; check_plain($node-&gt;node_title),
);


to 

$references[$node-&gt;nid] = array(
    'title' =&gt; $node-&gt;node_title,
    'type' =&gt; $node-&gt;node_type,
    'rendered' =&gt; check_plain($node-&gt;node_title),
);