Create content type with database connection

Hello,

I would like to create a new content type in H5P that loads content from a database (Drupal 7, PostgreSQL).

I find it hard to make my way from the Hello World greeting card tutorial to such a complex plugin.

It would be helpful if anybody could tell me if there is already a plugin with database connection where I can look at how it works. Or if anybody could tell me what to read to get all the information I need.

falcon's picture

Hi! I don't know of any plugins that does that. I think you have two main choices at the moment. (1) You could get the data from the database when the content loads and inject it into your libraries data in json format using hook_h5p_filtered_params_alter or (2) you could do this through ajax.

Thank you for your quick response! I wanted to create a calendar in H5P but now I'm unsure if H5P suits my requirements. My calendar was supposed to hold events that Drupal users add. And other Drupal users should be able to show that they participate in these events including things they bring with them.

Using JSON/Ajax seems to be a solution to read data from the database but could it also pass information from that H5P calender back into the database?

Example:

User A provides an event next week. User B says he takes part and brings something to drink (from a drop down menu). User C takes part and brings something to eat. So the calendar should show 3 participants in that event with drinks and eats.

For me it looks now like it would be a tricky thing to code and not really easy reuseable for others.

falcon's picture

The ajax requests could both read and write yes, the case in itself doesn't seem to leverage much of the strengts in H5P so if you're not going to use this in combination with other H5P content types or needs the H5P authoring tool to configure it for instance I probably would have implemented this without using H5P.