You are here

function auto_menutitle_nodeapi in Auto Menu Title 6.2

hook nodeapi function to store/retrieve/set auto_menutitle states

File

./auto_menutitle.module, line 65
Allows the menu title field to be automatically populated with the contents written into the node Title field

Code

function auto_menutitle_nodeapi(&$node, $op, $teaser) {
  switch ($op) {
    case 'insert':
    case 'update':
      if (isset($node->menu['mlid'])) {
        $res = db_query('UPDATE {menu_links} SET automenu_state = %d WHERE mlid = %d', $node->menu['fixtitle'], $node->menu['mlid']);

        //var_dump($node->menu);exit;
      }
      break;
    case 'presave':
      if (variable_get('amt_' . $node->type, '') == AUTO_MENUTITLE_ENABLED_PATTERN_ON) {

        // lets do our menutitle token calculation here.
        $pattern = variable_get('amt_pattern_' . $node->type, '');
        if (trim($pattern)) {
          $node->changed = time();
          $node->menu['link_title'] = _auto_nodetitle_patternprocessor($pattern, $node);
        }
      }
      break;
  }
  return;
}