Initializing 2.x branch
[project/newsletter.git] / modules / subscriber / README.txt
1 Introduction
2 ------------
3 The Model Entities module provides a fully working yet generic example
4 about what is good practice in creating and administering entities and integrating
5 entities with the rest of Drupal Core and the Drupal ecosystem.
6
7 It is also a way to quickstart your entities development as the code can directly
8 be used in your own project.
9
10 As mentioned the code tries to remain as generic as possible so as to not to distract
11 away from the main issue and allow you to literally copy and paste into your own project.
12
13 This module does not provide any functionality to non-developers.
14
15 Installation
16 -------------
17 Once you activate the module it sets up an entity administration interface under
18 Admnistration > Structure > Model Types
19
20 You can add model entities via
21
22 Administration > Content > Models
23
24 Keep in mind that you need to create some Model Types before you can add entities.
25
26
27 Using the code in your projects
28 -------------------------------
29 The way I envision using the module in my own projects is, for the time being,
30 searching and replacing the word "model" with the actual name I want to give my
31 entity and the base entity table and then adding the domain specific functionality.
32
33 It would be nice if this could eventually develop in something that is automated
34 so via a drush script we can get all the code ready to go.
35
36 Customising your entities in 3 simple steps.
37 --------------------------------------------
38 1. The first step is to customize your table in module.install by adding any column
39 tables specific to your entity.
40
41 Your would only every really need to change the Model entity and Model type as ModelType
42 is simply there to provide a means to represent your different entity bundles.
43
44 Also keep in mind that if you can get away with adding data only in serialized form in
45 the data column you can avoid doing anything to the tables.
46
47 2. You would then want to customize the edit form for your entity - which you will find in
48 model.admin.inc and customize the behaviour of your entity on save, delete which you
49 do via the ModelController class in model.module.
50
51 Currently, I am overwriting the create function to add some extra info. If you stick to
52 the $data variable and save extra data in serialized form (and not adding new columns
53 to your table)  - just like the model entity does with the checkbox - there is nothing
54 else you need to do. If you have added new columns you need to add support for them
55 in $model->create but not necessarily $model->save unless you are doing something specific.
56
57 3. Finally you can play around within the theming for your entity by looking into model.tpl.php and
58 model-sample-data.tpl.php
59
60
61