Hi,

I am trying to build a Drupal site where the node title is computed by adding some existing CCK fields, and it's really a big pain.

I have found the auto node title module, wich already does half of what I need. This code hides the title form fields from the node types I choose, and it changes the node title to the content type.
Instead of the content type, I want the title to be 3 custom fields, I already managed displaying this title in the a views page with this code:

<h2 class="review"><a href="<?php print $url; ?>"><?php  print $field_year_value;?> <?php print $term_node_1_name; ?> <?php print $field_model_designation_value; ?></a></h2>

However, using the method only gives me more problems and inconsistencies. So hopefully we can change the module code below to use my CCK fields rather then content type for a title.
I have some experience messing around with php code, but the code below that generates $title is beyond me, I don't get what's going on with the % signs.

Task:
-Modify the auto node title module to turn the title into the CCK variables that I printed in the code snippet above
-Document all the changes you made so that I can easily do it again myself but with other variables
-All work must me done in the module itself and if neccessary in phptemplate files. No changes in core and other modules.

Please send me your quote + estimated time of development to: jurriaan_roelofs at hotmail.com

this is the node title module code:

// $Id: auto_nodetitle.module,v 1.3 2006/08/29 12:24:11 fago Exp $

/**
 * @file
 * Allows hiding of the node title field and automatic title creation
 */


/**
 * Implementation of hook_help().
 */
function auto_nodetitle_help($section) {
  switch ($section) {
    case 'admin/modules#description':
      return t('Allows hiding of the node title field and automatic title creation.');
  }
}

/*
 * Implementation of hook_form_alter().
 */
function auto_nodetitle_form_alter($form_id, &$form) { 

  if (isset($form['type']) && $form['type']['#value'] .'_node_settings' == $form_id) {

    $form['submission'][$form['type']['#value'] .'_auto_nodetitle'] = array(
      '#type' => 'checkbox',
      '#title' => t('Automatically generate the node title and hide the node title field.'),
      '#weight' => -5,
      '#default_value' => variable_get($form['type']['#value'] .'_auto_nodetitle', 0),
    );
  }
  else if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
    //this is a node form
    if (variable_get($form['type']['#value'] .'_auto_nodetitle', 0)) {
      $types = node_get_types();
      //node id is only available for node updates
      $title = ($form['#node']->nid) ? t('%type %node-id', array('%type' => $types[$form['type']['#value']], '%node-id' => $form['#node']->nid)) :
                                       t('%type', array('%type' => $types[$form['type']['#value']]));
      $form['title'] = array('#type' => 'value', '#value' => $title);
    }
  }
}

Comments

wuf31’s picture

It can be done without patching core.. but only in 5.0
IMO, to get this working in 4.7, at the very least.. CCK has to be patched.
I may be wrong, but that's the way I see it.

-=- Jhon -=-

jurriaanroelofs’s picture

Nope, I just got it done. Jonathan from openpackage.biz helped me out and it works just fine.

-------------------------------
http://www.sooperthemes.com/#-Drupal-Themes

technivant’s picture

Peach,

I've been digging around on drupal.org for 3 days trying to figure this out. Would you mind sharing how you did this?

Thanks!
TWSP

jcapote’s picture

I agree, can you please share?

This is really frustrating, not being able to do this.

jurriaanroelofs’s picture

Sorry I dont know what the guy did I just got the module back but customized to my site.

-------------------------------
http://www.sooperthemes.com/#-Drupal-Themes

ablemike’s picture

Can anyone point to a way to do this in 5?

stefan vaduva’s picture

It looks like the author of this thread has forgot about it :( Too bad.. I was interested to find out how to do this also

[edit] I see now that this was a paid service, so I can understand why the author of this thread didn't want to share the solution. He paid for it, so it's normal to keep it for himself.

lsommerer’s picture

If I followed the original question, it seems to me you can do this with the Automatic Node Title module and the token module (in 5.x). I just put together a simple equipment reservation system for our school with CCK and a few helper modules, and I needed to compute the title for that project (you can read about it here).

(edited links now that site is live)

jurriaanroelofs’s picture

It's not at all like that, I'd love to share how to do this but I don't know :)
I hired some guy to do it and he send me back a module that produced a node title with the fields on my sites that I wanted in there, I have no idea how he did it, if anyone wants to look at the code of the modified module just contact me through my contact form and I'll send it right over.

-------------------------------
peach from All Drupal Themes

-------------------------------
http://www.sooperthemes.com/#-Drupal-Themes

stefan vaduva’s picture

I've managed to solve the problem like this: http://drupal.org/node/191435#comment-653417