CTLModuleMaker 2.0.3 - how to set hierarchy in Routes.php

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
franciszeks
Forum Members
Forum Members
Posts: 10
Joined: Thu Jan 18, 2007 10:34 pm

CTLModuleMaker 2.0.3 - how to set hierarchy in Routes.php

Post by franciszeks »

I can't find it in FAQ or anywhere. How to modify Routes.php to add other hierarchy to my entities?

That's the code - if someone can explain it to me I would be grateful.

Code: Select all

<?php
		$hierarchies = array();
		$routes = array();
franciszeks
Forum Members
Forum Members
Posts: 10
Joined: Thu Jan 18, 2007 10:34 pm

Re: CTLModuleMaker 2.0.3 - how to set hierarchy in Routes.php

Post by franciszeks »

anyone?
User avatar
plger
Forum Members
Forum Members
Posts: 196
Joined: Wed Oct 15, 2008 10:38 am

Re: CTLModuleMaker 2.0.3 - how to set hierarchy in Routes.php

Post by plger »

The FAQ explains how to add Routes.
At this point in development of CTLMM 2.0, you shouldn't even know what Hierarchies are for. That is, I don't think there's anything you want to do that strictly requires it (they're just a shortcut to a bunch of settings, and not yet fully implemented).
Let me know precisely what (what kind of output or result) you wish to accomplish, and I will try to help you get there.

Plger
franciszeks
Forum Members
Forum Members
Posts: 10
Joined: Thu Jan 18, 2007 10:34 pm

Re: CTLModuleMaker 2.0.3 - how to set hierarchy in Routes.php

Post by franciszeks »

I just wanted to reorder tree-like hierarchy of entities in admin panel of my module to make it more logical (for example: Adresses is child of Cities, and in other seperate branches I see other entities which make other logical trees). Now I see that this is not important for module to work just fine and there are routes for frontenduser which mask no hierarchy in admin section.
User avatar
plger
Forum Members
Forum Members
Posts: 196
Joined: Wed Oct 15, 2008 10:38 am

Re: CTLModuleMaker 2.0.3 - how to set hierarchy in Routes.php

Post by plger »

Hi,
if each child entity belongs to only one parent entity, you can also build your module using the "child" field type (and setting the child entity as non-autonomous). The help gives some info on that. In this way, the admin panel will also display the hierarchy: one will have to get into a parent entity in order to be able to edit its child entities.
plger
breadfarms
New Member
New Member
Posts: 2
Joined: Fri Feb 25, 2011 1:29 am

Re: CTLModuleMaker 2.0.3 - how to set hierarchy in Routes.ph

Post by breadfarms »

Hello,

I am new to CMSMS and CTL Module Maker, and I was wondering if you guys could help me figure out to create a entity and link it to a parent.

I have looked through the example but I don't understand it. The example reads,


Example 1: Library module

Let's take again our classical example of a hierarchical module: a library module. We wish to classify our books in the following way:

* Book type
o Genre
+ Book


To give it some reality:

* Fiction
o Science-Fiction
+ Fahrenheit 451
o Romance
o Suspense

Then it reads: In order to link them together, we will have to create a field in Genres that will hold it's parent (for instance a dropdown field, specifying the name of the database table). The same should be done with Books. Although the structure supports multiple children (with the "child" field type), this wizard is not to that point yet.

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.

Is there anyway someone could walk me through the process of setting up.

What do I set the child entity to (autonomous or non-autonomous)
Then how do I make the Genre a child of Book Type

Any assistance you can provide would be greatly appreciated.

Thanks
Benjamin
User avatar
plger
Forum Members
Forum Members
Posts: 196
Joined: Wed Oct 15, 2008 10:38 am

Re: CTLModuleMaker 2.0.3 - how to set hierarchy in Routes.ph

Post by plger »

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
Post Reply

Return to “Modules/Add-Ons”