1

I have an sqlite database representing a collection of Foo which is immutable. I would like to be able to take this collection of Foo in the GUI of Drupal, and append a few fields onto each Foo instance, these new fields are to be editable.

I see no point to inserting the data as nodes / entities directly as the data is only going to reflect what's already in the database and inserting data using node_save is incredibly slow for duplicating the data.

How would I accomplish this so that a content-type / entity type uses data from another database, but manages a few additional editable fields?

Would it be a custom content type with a module to manage the pulling of the data from another database, or would it be a custom entity?

1 Answer 1

0

I would use a custom content type that stores the primary key (pk) of an instance of Foo as text, integer or whatever you need, just that one field. Let's call the content type Bar.

Then for display create a node template for Bar that:

  1. Queries your database by sending Bar->pk and returns the Foo row/object
  2. Iterates through the fields in the row and displays them where and how you choose

In case you haven't already come across it, if you're intending to use an external database, it is best to define it in your settings file and call it when you need it as described here.

2
  • would this allow the data to be searchable, and viewable with views? Commented Nov 20, 2014 at 22:57
  • Ahh, now that's a different question, searching the content inside your external db would require a fairly complicated custom module I think. Better off replicating the data as nodes, just export as csv or xml and use Feeds to import into a content type.
    – Darvanen
    Commented Nov 20, 2014 at 23:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.