We help IT Professionals succeed at work.

Updating a field with a wysiwyg editor using Drupal?

Dalexan
Dalexan asked
on
I have installed Drupal on our internal network and would like to use it to modify fields within our mysql database. I have read and installed CCK but before I dig deeper into this I want to pose this question to see if I'm going in the right direction.

I have a field that I would like to modify in a mysql database on a different server. This field contains HTML that is displayed on a 3rd party application. I simply want to display a wysiwyg editor that loads this fields contents and allows the user to modify and save the field. How can I accomplish this without writing a custom module?

Step 1: user logs into drupal

Step 2: user clicks on a link to modify HTML from the database field

Step 3: Drupal or CCK module selects the field and displays in a wysiwyg
Select value from viewer_text where position = 1

Step 4: user changes the HTML within the wysiwyg and saves
Update value from viewer_text where position = 1

I'm just stepping this out as in how I think this could happen I dont know if this is possible, what modules would I need to install etc...
Comment
Watch Question

Commented:
Hello Dalexan,
Short answer: You can't. You'll need to create something custom.

There aren't a lot of modules that will connect to a database on another server, period. Also, anytime you get into different tables in a database that other modules aren't using, you need to create a module that handles that data. That's why I answer as I do.

Now, Drupal can connect to multiple databases. Here's more reading:
http://drupal.org/node/18429

It always becomes quite the cluster though when making use of multiple servers, and probably even more if connecting to some custom table/field on another server. If it's another Drupal install, perhaps you can replace "localhost" with your other server's ip address or web address if you can access the db by other means first.

Ow my head is starting to hurt now.

Sorry it's not a happy easy answer. Hope this helps clarify.

Best regards,

Chris

Author

Commented:
Thanks, That was what I was afraid of. The drupal install is hosted in house and needs to connect to a custom table / non drupal on another server.

Oh well, any help you can give me on writing a very simple module to make this happen?

Commented:
"Simple" may not be possible. However, here's a few questions to ask and ideas:

Without Drupal, can you connect to your other server's database remotely? Check out php example #2 here:
http://php.net/manual/en/function.mysql-connect.php

If not, proceed no further or: On the other server, try to get it configured to work that way. If you can't, try writing a REST API on that other server unless the data has confidential info or you don't have access to do so...

Maybe try transferring the databases to one server for best ease of use (I know, probably not that easy).

Warning: You'll be running SLOWLY if making MySQL requests from long distance calls on another server.

It looks like Drupal 7 has a nice HTTP request function:
http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_http_request/6

How to make a Drupal module (must read):
http://drupal.org/developing/modules

Let me know if that helps. :)

Author

Commented:
Yes, I can connect to the other servers database. These are all in house servers which I have full access to.

There's lots of information in the "How to make a drupal module"

I think I may post another question to get some help creating that module. It should be very simple to do in PHP as a custom module?

Select value from viewer_table where position ='1'

Display the results of this select in fckeditor and allow the user to edit it.

Once the user is done editing it update value from viewer_table where position = '1'

Commented:
Perhaps that would be another question. However, these might be useful:

TableField (might be just the thing you need?)
http://drupal.org/project/tablefield

and that other Drupal db connect page I mentioned so that you can integrate drupal calls with the db:
http://drupal.org/node/18429

After that, it's beyond my comprehension level for now. Still learning the ropes of module development myself. :)

Best regards,

Chris

Author

Commented:
TableField looks like its for building an HTML table on a node dynamically. Its not actually selecting data from a database table and returning it to a node....

I think I can just federate the database/table I need to the local drupal server install to get around remote db connect issues.

I think I will need help with the PHP syntax in coding the custom module to accomplish this.

Commented:
Ah got it. I wish you success! I'll keep an eye out for answers on your new question as I'm curious about this myself now. I want to create a custom table for an upcoming project, and a handy CCK field would help with that.

Author

Commented:
Its best to stick to the short answer for this question " YOU CANT "

Currently there is no module available to tie database tables outside of the drupal database to a form without writing a custom module.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.