Hi,
breadfarms wrote:I don't understand what this means. (create a field in Genres that will hold it's parent) Because when I create genre as an entity if I make it autonomous it shows up in the new module underneath but not connected to Book type, However if I set genre to non-autonomous it does not even show up in the new module. Not even inside the Book Type entity.
First, autonomous means to control just that: whether one can manage these entities directly (in which case it shows up in the entity menu), or only through another entity - in which case it will show up when editing the parent item (provided that it has any). Therefore, in the second case you need to tell ctlmm that one entity is a child of the other.
I'll try to explain the two ways of setting up such a relation. To simplify this, I will assume that you have "category" as a parent entity and "book" as a child entity.
If you want your child entity to be non-autonomous (to be editable only through the parent entity), you will need the first way. Otherwise, you can use any of the two.
1) through the use of a "child" field type:
Create your book entity with all the attributes you want. (I'll assume that the name of the entity is "book")
Create your category entity with all attributes, and add an additional field of the type "child". Let's call this field "books". Now one of the options when setting this type of field is "What is the child entity?". Just enter "book" there.
Save and create your module. When editing a category, you will find a tab with its books.
2) through a parent field
This method is slightly less direct but offers much more possibility...
Create your category entity with all attributes.
Create your book entity with all attributes, and add a field of the "dropdown list" type. Let's call this field "parentcategory" (I would normally call it just "category", but here I want to make the difference explicit). Now we have to tell ctlmm that the options in this dropdown list are the different instances of the category entity. To do this, we'll specify the database table to use in "Name of options table". Let's say your module's name is "library", then the name of the table will be: "module_library_category". (You could choose specific fields in that table, but for now I suppose you don't need this so leave option value and option label empty).
Save and create your module. Add a category. Then add a book - you will have a dropdown with the choice of categories.
In your detail template for categories, if you want to display the books in that category, one method is just to call it
Code: Select all
{cms_module module="library" what="book" where_parentcategory=where_parent_cat=$item->id->value}
(see FAQ for more details on this part)
plger