I have a very simple question for all of you Drupal experts out there:
Suppose I have a module that is a node. I don’t like the default date field so I want to split date and time into 2 different fields. How do I do this?
and Do I have to care about how data is saved or retrieved once I’ve made changes to the node form?
You can do this by creating a custom template. If you know something about how templates work in Drupal than you know you can override the default templates with custom ones. It’s only a matter of finding the right template to override.
If you’re not sure what template you need to override, I suggest you use this handy module, which will also give hints about possible template candidates: Theme developer (make sure you disable it after you’re finished, because it injects markers and it can break you’re styling).
Let’s say you’re content type is called ‘article’ and you want to change how the date field is display in a node.
/sites/all/themes)node.tpl.phpfile (don’t directly add you’re changes here, because it will affect all your nodes)node-article.tpl.phpAnother approach would be to override the theme function that is responsible for rendering that date field (again, using the Theme developer you can find out what theme function is rendering that field). Assuming the theme function is named something like
theme_date($date), you can override the function in yourtemplate.phpfile (usually in/sites/all/themes/your_theme_name. You can always go fortheme_date($date)if you’re not sure what name to use.I would suggest using the second approach, especially if you just want to split the date. The first approach is more flexible, but is better used if you want to do major changes to the layout and formatting.