Greetings,

I was wondering if someone would nudge me in the right direction or perhaps give me a reality check. I've found a few posts which I believe speak to this issue, perhaps I just want it to be easier. I'm a designer catching up with the programming world and wanting a PHP cheat sheet.

My client has downloaded a new table into the Drupal database containing Account information for vendors. ID, Name, Address, Phone, (and eventually we'll add keywords (taxonomy), Long/Lang(gmap.)

Can I create CCK fields that call to that data (I'm trying autonodes but getting error message, have post to developer)

**** Dynamically create new pages for EACH Account (Cron?) *****

Client is using third party CRM and will download to MySQL on occassion - AND update Drupal directory.

Does not want to enter data into Drupal.

I've reviewed posts regarding using multiple databases, I'm just hoping there is an easier solution.

Your assistance is appreciated.

Comments

msjones design’s picture

Client doesn't want to upload via CSV, wants more automated update to MySQL

gforce301’s picture

Is the question can this be done? If it is, the answer is: yes code can be written to take data from a third party CRM and create drupal nodes out of it. That is the only way I can think of.

Easy solution? I seriously doubt it. What you are talking about would be, at best, a decently complex problem for a qualified developer. Such things have been written but none that are global or generic in scale as interfacing with other databases and software can be complicated.

If you leave the data in the "new table" and do not create drupal nodes out of it, sure you can write queries against it. Once again a moderately complex solution requiring knowledge of how to use php and mysql. Not one that can be easily solved with CCK without a good deal of custom code.

I wish I could tell you that there was an easy way to do this. Without knowing anything about this "third party CRM", not even so much as it's name, there is no other answer I could give.

msjones design’s picture

Thank you for your reply,

Rather than worry about the third party, more simply (and I'm sure complex anyway)

We wish to download data stored in a new table on the Drupal database and create new pages.

Can I create CCK fields that call to that data (I'm trying autonodes but getting error message, have post to developer)

If I figure out this autonode error will it dynamically create nodes for me and do I then have my solution?

gforce301’s picture

I am not familiar with the autonode module so I can not tell you for sure.

imrook’s picture

The Autonode module doesn't do quite what you want. It provides a single CCK field that allows a value to be entered to populate various other fields for the node. It still requires you to create nodes. This seems to be the whole point of your project -- creating new nodes in Drupal as new contacts are entered in the CRM. I agree that there are no canned solutions for this because requirements and implementation are usually different case-to-case. In the end, I think your solution will have the following components:

  • Cron job
  • Custom module to automate node creation

The cron job will run at some interval and get a list of newly added contacts. The custom module will automate the node creation and set the appropriate status so that the next list of new contacts does not include repeats. I think you're going to write less code this way than trying to wire up autonode.

Another option is to create a new CCK field module that allows you to specify a field and an index into a table. Then when the node is loaded, the CCK field will get the most recent data from your other table. Your cron job then becomes a MySQL database import. Coding CCK field modules is not easy. There are a lot of hooks and not a lot of documentation. I'm not sure what your level of experience is, but a general rule of thumb is the nicer a solution sounds, the more complex you can expect it to be to code.

dman’s picture

I think I like the sound of that last solution, it's the least messy. But not saying it isn't tricky!

The problem with any of these tasks is the joining on unique IDs.
Each row in the foreign table must be made to be a node within drupal ... if you are to use the rest of the drupal goodness in other ways.
Assuming the foreign data table may have things added,removed or changed, your mission is to trigger drupal node updates to respond to that. So that's a big API to write.

Simpler, is to write a batch job that regularly (or on demand) imports/compares from the foreign table and updates/adds/deletes nodes accordingly. This is also tricky, but comparatively more do-able. ASSUMING that you can find some unique key or ID in the source data to index against. ... which is probably what imrook was saying :-)

In practice, I've found those tasks to be liable to flood the db with duplicates unless written carefully. You shouldn't trust foreign keys ... but you have to at some point.

If you are more than a few thousand records, the batch job is less viable, and you need a database replication-type queue or last-updated timestamps or semaphores everywhere. horrible.

.dan.
if you are asking a question you think should be documented, please provide a link to the handbook where you think the answer should be found.
| http://www.coders.co.nz/ |

msjones design’s picture

I'm not a programmer 'aint it a shame!? Okay I'll head towards the documentation on how to write a module and reread your posts... Thank you kindly for your replies. more comments and suggestions welcomed!

paganwinter’s picture

I am working on a gaming portal and here is what I want to do:

I have a table with info of the games (Name, path for the flash file, image etc).

I need an index page of the games, created dynamically by fetching the data from the table. This page should provide me a link to each of the individual games' page.
I need a way to dynamically create pages for each of the games, again by fetching data (Name, path of the game's .swf file) from the table.

I have achieved this to some extent. I have an index page which is static and I have individual game pages which are again statically created.
I need some way of automating this. So that I just need to maintain the table with the list of games along with their data (Image, path etc.)

I have found one way of doing this too, using node_save(). This way each time I add a game to the table I'd have to create a node for that particular game by calling node_save().
Then I need to figure out a way to get the urls for each of the dynamically created game pages (nodes) which I'd need in the index page to link to the game's page.

Can this be actually done? That too with clean URLs?

OR

How about passing the game's details as an argument to the games link from the index page and have a generic game play page which would fetch relevant game details from the database depending upon the requesting URL?

Something like this?

Index page:
Game1 (/games/game_page?game_id=1)
Game2 (/games/game_page?game_id=2)
Game3 (/games/game_page?game_id=3)

Then the game_page node would just construct the page depending on the game id i sent through the requesting url.

I don't know what I have just typed out! Aaargh, am going mad!
Please if anyone finds sense in this, please let me know.

paganwinter’s picture

The last solution actually worked!!! :D
So no need to 'automatically create and store nodes'.
You could have a genuinely dynamic node! With plain old PHP.

So now I have an index page which fetches a list of games from the database.
The games then link to the game play window and I pass the game ids as URL encoded arguments to the game play window which then calls and loads the corresponding game's .swf file, again from the database.
:)