Skip to content

Commit 1e9d260

Browse files
committed
Merge branch 'hotfix/SUPPORT-1218-document-update'
2 parents c4eb4bc + 0730e59 commit 1e9d260

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

modules/loop_documents/loop_documents.module

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,32 @@ function loop_documents_node_update($node) {
326326
if ($node->type === 'loop_documents_collection') {
327327
loop_documents_create_collection_menu($node);
328328
}
329+
else if ($node->type === 'loop_documents_document') {
330+
// Fetch entries that qualify for being the menu item.
331+
$result = db_select('menu_links', 'm')
332+
->fields('m', array('link_path', 'router_path', 'mlid'))
333+
->condition('router_path', 'node/%','=')
334+
->execute()
335+
->fetchAll();
336+
337+
// Look for the actual menu item. Alter the menu item.
338+
foreach ($result as $value) {
339+
$link_path_arr = explode("/", $value->link_path);
340+
if($node->nid == $link_path_arr[1]) {
341+
$menu_link = menu_link_load($value->mlid);
342+
343+
// Use menu link title if one is provided, else use node title.
344+
if(empty($node->menu['link_title'])) {
345+
$menu_link['link_title'] = $node->title;
346+
}
347+
else {
348+
$menu_link['link_title'] = $node->menu['link_title'];
349+
}
350+
351+
menu_link_save($menu_link);
352+
}
353+
}
354+
}
329355
}
330356

331357
/**

0 commit comments

Comments
 (0)