By zwhalen on
Hello,
Sorry if this is a really basic question, but I'm pretty new at this (drupal) and I'm trying to get used to the structure. Here's my problem:
I want to create a new content type, but I need some functionality that I can't include with flexinode. I think I can set up the structure for the data itself, but how do I make a new node type (with appropriate fields, etc.) and a link to it available under 'node/add' ?
I searched and looked through the handbook, but I couldn't find this specific information.
Thanks in advance,
Zach
Comments
take a look at existing modules
When I started out learning how the modules worked, what I did was take a simple module that creates a new node type (I used the Page module), and more or less copy it and then hack in the functionality you need... you'll have to change all the function names to whatever your new node type is named. Going through each function in a small module like that is a good way to get some context for the API functions.
Also look through the drupaldocs.org site and pay close attention to the hook_ functions
Good idea. I wasn't sure
Good idea. I wasn't sure how the hooks worked, but that helps.
Thanks!
Unique db table?
As a new user, this helped a ton to create simple content, but what if I'd like to use data from a unique database table. The db fields are setup and hook_form looks like it can mirror those, but how do I tie it to this unique db table?
You need to implement several hooks
You will need to implement the load, insert, update and delete hooks. And you will probably want the validate hook.
If you look under 'Handbooks' you will see an entry for Drupal API, click that, select which version of Drupal you are developing for and see the section on hooks.
Hooks for Custom DB Tables
Is there a barebones example for the following hooks - load, insert, update, delete, validate?
I'm assuming that many others in the community have already done this, but adding db tables seems essential for customization. For a new user, reading code and grabs bits from other files is always the way to understanding a system, but this just seems like it could be built very simple and then expanded upon.
My primary goal is to get a basic db table integrated into Drupal - that being the foundation of so much more.
If there are no examples, I'd be happy to contribute mine. Here is the example I'm starting with...
locations
- UID
- name
- description
Check out the handbook
The handbook has a section on the Drupal APIs including the module hooks. There is also a sample module at http://drupaldocs.org/api/4.6/file/contributions/docs/developer/examples... that would probably help.
why not flexinode?
I'm curious why you think flexinode can't do it?
It's far easier to write a new flexinode field than to create a whole new module.
Flexinode and custom db table?
Because I already have the database table complete...
Is there a way to use flexinode, but point it to my custom table?
Also read this
In any case, be sure to read Converting 4.6 modules to HEAD.
If you develop a module, do you want it to work with Drupal 4.6, or with the upcoming 4.7? There are some important differences between both, and a 4.6 module will _not work_ in 4.7 and vice versa.