function LinkitPluginEntity::buildReverseMenuTrail in Linkit 7.2
Builds a reverse menu trail for the entity.
Parameters
object $data: An entity object.
1 call to LinkitPluginEntity::buildReverseMenuTrail()
- LinkitPluginEntity::buildDescription in plugins/
linkit_plugins/ linkit-plugin-entity.class.php - Build the search row description.
File
- plugins/
linkit_plugins/ linkit-plugin-entity.class.php, line 122 - Define Linkit entity plugin.
Class
- LinkitPluginEntity
- @file Define Linkit entity plugin.
Code
function buildReverseMenuTrail($data) {
$vars = array();
$output = '';
$uri = entity_uri($this->plugin['entity_type'], $data);
if (isset($uri['path'])) {
$menu_link_fields = array(
'link_title',
'link_path',
'plid',
'menu_name',
);
$menu_items = db_select('menu_links', 'ml')
->fields('ml', $menu_link_fields)
->condition('link_path', $uri['path'])
->execute()
->fetchAll(PDO::FETCH_ASSOC);
foreach ($menu_items as $menu_item) {
$vars['reverse_menu_trail'] = array();
while ($menu_item['plid']) {
$menu_item = db_select('menu_links', 'ml')
->fields('ml', $menu_link_fields)
->condition('mlid', $menu_item['plid'])
->execute()
->fetchAssoc();
if (isset($menu_item['link_title'])) {
$vars['reverse_menu_trail'][] = $menu_item['link_title'];
}
}
$output .= !empty($vars['reverse_menu_trail']) ? theme('linkit_reverse_menu_trail', $vars) : '';
}
}
return $output;
}