Hello,

I’m Roy this is my first post:

I’ve Just installed drupal to try and learn more about it. I’ve used joomla for a long time but it can’t do what I want.

I want a CMS to handle my community communications login etc. But also I want to develop php that stores information on a database using the user or member id from the CMS.

I believe I can literally code my php and have it within drupal is that correct?

If so can you give me some pointers where to start

Thanks

Roy

Comments

Roberto Gerola’s picture

Hi Roy.
Yes, you can do that.

You can write your own modules and, using hooks provided from Drupal core,
interact with the system and store additional informations that you need
in the database in your own tables.

A good starting place are the handbooks :

http://drupal.org/handbooks
http://drupal.org/contributors-guide
http://drupal.org/node/508

Roberto

webchick’s picture

It depends on how exactly you want the two systems to interact, but custom PHP can be used in several places in Drupal:

  • Inside "blocks" (the stuff you see on the side here with "new forum posts" and the like) -- you can throw some custom PHP to show the 5 newest blog posts, for example.
  • Inside "nodes" (any content you create; forum posts, pages, blog entries, etc.) -- you can throw some custom PHP to do everything from display the current date/time, to call in other pieces of content dynamically.
  • Inside "modules" (these are actually all code; extensions which can make Drupal do fancier stuff) -- more advanced; you can do just about anything. ;)

For instance, each time a new user registers, you might want to save their user ID to a separate table for your external system. You could do this with a custom module that implemented a "hook_user" function:

// This would be in a file called 'custom_module.module' in the modules directory
function custom_module_user($op, &$edit, &$account, $category = NULL) {
  if ($op == 'insert') {
    // A new user just registered and is being added to the database.
    // Store that user ID value in the external system table.
    db_query('INSERT INTO external_system_table (user_id) VALUES (%d)', $user->uid);
  }
}

(note: that's totally untested, and it's very late here, but should be pretty close ;))

"Hooks" are Drupal's way of letting modules modify and extend "core" behaviour without hacking any core source code! They're very powerful and there are almost limitless things you can do with the flexibility.

Hope that helps answer your question.

nomax5’s picture

I’ve read some of the handbook and created the “onthisdate.module” had a look at copying the story.module

But I have this website idea burning a hole in my keyboard so I need to get that coded up then I’m confident I can incorporate it into drupal

If you could just push my luck and ask one more little bit of advice:

I’m doing this site which gathers some information
Writes it to tables
Allows the visitor to change or delete it
Add another chunk of information
See a list of their chunks
All owned and controlled by that visitor / member

Other visitors can see view a lists

Basic form db stuff

So this is what I’m planning (please advise):

I see the drupal “user” is stored in an INT(10) field so I’ll make it that size on my tables.

I am writing the code with no html style formatting whatsoever just raw ugly html and php. I’m thinking all that stuff will be taken from what ever theme my drupal site is using.

I’m hoping that I will be able to covert is into modules quite easily.

What I’m not confident in doing is learning Drupal and a new website idea at the same time. The idea has some very complex aspects to it, it’s a bit like developing a search engine.

Is there anything I should watch out for?
any tips or advice?

Roberto Gerola’s picture

Hi Roy.

For what I understand, a new module will solve your needs.
If you don't wnat write a new module, you could also try out the CCK module that permits you
to create dinamically new content types.

About html output. Yes, a part of html must be put in the module and another part in the
theme. It is up to you how much html code put in php code (I suggest the minimum).

Yes, I agree with you. Learning Drupal and at the same time developing a new module could
require a little more effort.

Perhaps, you can separate the two activities in two different steps ?
So when you'll be a little more confident with Drupal you can work on your new module ?

Roberto

he_who_shall_not_be_named’s picture

nomax5’s picture

I had a look at that cck module I don't think it's going to be able to do what I'm wanting to do thanks anyway roberto

I've developed my site - it turned out to be alot more complicated than I origianlly thought.

I'm stuck now trying to figure out how to develop modules, the onthisday tutorial is difficult seeing as I don't have any content.