--- custom_breadcrumbs.module 2009-08-02 18:18:48.000000000 -0500 +++ patch_custom_breadcrumbs.module 2009-08-09 03:14:20.000000000 -0500 @@ -201,6 +201,72 @@ function custom_breadcrumbs_form_alter(& '#weight' => -50, ); $form['custom_breadcrumbs']['breadcrumb_table'] = array('#value' => $output, ); + + + // hook form alter to add the bredcrumb in the node/add page + // we get the path from the node/nid but since the nid + // is created after the form submit we can't create + // breadcrumbs if the node hasn't been created + // I made a small change to _custom_breadcrumbs_paths_get_breadcrumbs + // to use the node/nid instead of the url to be able to use this + // couldn't figure it out a way to do this so we + // just allow the breadcrumb to be set if the node already has an nid + if(!empty($node->nid)) { + // we set the $path to the node/nid + $path = 'node/'.$node->nid; + $breadcrumb = NULL; + // instead of using the $bid to load the breadcrumb of this node + // we use the specific_path column from the table custom_breadcrumbs_paths + // the reason of this is just because I couldn't figure it out a + // way to load the $bid since + // in the settings page we get the $bid from the arg(5) + // like 'admin/build/custom_breadcrumbs/path/edit/$bid' + // but in the node I couldn't find a way to have access the the $bid + // maybe it would be a good idea to create a whole new module + // custom_breadcrumbs_node and save in the table the nid of the node + $breadcrumbs = custom_breadcrumbs_load_breadcrumbs('custom_breadcrumbs_paths', 'custom_breadcrumbs_paths', array('specific_path' => $path)); + $breadcrumb = array_pop($breadcrumbs); + + // we group everything in a fieldset + $form['breadcrumb'] = array( + '#type' => 'fieldset', + '#title' => t('Breadcrumb'), + '#access' => user_access('administer custom breadcrumbs'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + ); + // we need the specific_path to get the value of the $path + // in the form of node/nid + $form['breadcrumb']['specific_path'] = array( + '#type' => 'hidden', + '#required' => TRUE, + '#default_value' => $path, + ); + $form['breadcrumb']['titles'] = array( + '#title' => t("Titles"), + '#type' => 'textarea', + '#description' => t('A list of titles for the breadcrumb links, one on each line.'), + '#rows' => 3, + '#default_value' => $path ? $breadcrumb->titles : NULL, + '#collapsed' => FALSE, + ); + $form['breadcrumb']['paths'] = array( + '#title' => t("Paths"), + '#type' => 'textarea', + '#description' => t('A list of Drupal paths for the breadcrumb links, one on each line.'), + '#rows' => 3, + '#default_value' => $path ? $breadcrumb->paths : NULL, + '#collapsed' => FALSE, + ); + $form['#table'] = 'custom_breadcrumbs_paths'; + // there's another issue here. we keep saving the breadcrumb into + // the database on every form submit, even if there's no changes + // is not really a problem because the module takes the last + // record and uses it as the breadcrumb but the table + // will get bigger this way + $form['#submit'][] = 'custom_breadcrumbs_form_submit'; + $form['#validate'][] = 'custom_breadcrumbs_form_validate'; + } } }