Tutorial and API documentation

Django Philipp's picture

To learn the ECK faster by myself, I'm now trying to write a programmer's tutorial and an API reference in the style of the django documentation
https://docs.djangoproject.com/en/1.4/intro/tutorial01/

Are there good examples of modules using the ECK?

You can also help me with a hint about how to add and modify bundles using code. I didn't see anything about that in the existing documentation (but with mouseclicks, it's very simple).

Philipp

Comments

I don't know of any modules

fmizzell's picture

I don't know of any modules that are using ECK to manage their entities. I think part of the problem is a misconception that ECK is just a UI to create entity types. I am trying to change that by refactoring some modules that use entities to use ECK, but there is nothing final yet.

As for bundle creation, you can look at the file eck.classes.inc. The Bundle class is what is used to create new bundles. If you look at the save() function you will notice that all that is required is a name for the bundle, and the entity type that bundle belongs too. So it might look something like this

$bundle = new Bundle();
//the name is a machine name for the bundle
$bundle->name = "my_bundle";
$bundle->entity_type = "entity_type_name";
$bundle->save();

That should be it. I will add this documentation to d.o (drupal.org) when I get some time, but also feel free to add your documentation there, anybody can create new pages, and edit the documentation in d.o

Attaching fields to bundles

Django Philipp's picture

Hi! What's the best way to attach a field to a bundle? Using field_create_instance() inside hook_install()?

EDIT: I've just tried this and it works. The ammount of required code is acceptable. But if you have an even better solution, tell me!

That is the way I used to do

fmizzell's picture

That is the way I used to do it, but lately I have been using the features module. I do the configuration from the UI (attaching the field to a bundle) and then I use features to save it to a module. You can save your entity types and your bundles to code with features too.
Also, one of eck maintainers, wrote some code to make it easier to attach fields, but the patch has not been reviewed or commited. Here is the issue with the patch: http://drupal.org/node/1434238

Django Philipp's picture

It is first of all written for myself, because I'm currently trying to get a better understanding of the concepts of drupal and the ECK.

You find the tutorial at
http://django-tutorial.de/eck_tutorial_1.htw

I'll continue to improve and to extend this. If you find something there which is complete nonsense, please tell me. As soon as I get a clear conception of the ECK, I'll begin to edit the documentation at drupal.org.

Entity Construction Kit (ECK)

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week