Dear screenreader-user, please let me know, if I can make any improvements for your convinience. Mail me to "n" dot "company" at "mac" dot "com". Thank you.
Skip to the navigation. / Zur Navigation springen. Older Entries / Ältere Einträge Skip to the search. / Zur Suche springen. Skip to the content. / Zum Inhalt springen. Skip to the bottom. / Zum Ende springen.
Fullscreen-Modus einschalten um die Artikel besser lesen zu können.
Update: don’t bother – I’ve found a much simpler solution and will update this tutorial soon! In the meantime, check out the extension on github where I’ve implemented the easy solution.
I was looking for a tutorial that explains how to create true m:n relational objects with Typo3 and Extbase and Fluid. Unfortunately I could not find something that explained how I could get this to work with the Extension Builder. I finally figured out a working solution. This post will be a short tutorial on how to accomplish “has many and is child of many” relations with the Extbase Extension Builder.
This tutorial will show you, how to create an extension with an object “category” which can have subcategories of the same type. You can create Categories and Subcategories. You can also assign multiple parent categories to subcategories and so forth. The relation will be visible on both ends.
First, you need to create a new extension. Switch to the Extension Builder and enter some details for your extension. In my case I create a new extension nbomn :
Hit “save” after you have created the basics.
Now we are going to create a new Model “Category”. It is of the type “Entity” which is an object that has a unique identity. Much like a car – compared to a value object which would be more like a color that only has a meaning when applied to a subject (car) but can’t stand for it’s own. It’s also an aggregate root – this means the extension builder will generate a repository and default controller actions for this model so we can easily fetch and save objects – this has nothing to do with the m:n relation.
Now that we have created the Model, let us add some properties. First and most obvious, we need a name for the category – this is of the type “String”, and it’s also required. Second, we need a new field that acts as the counterpart for the m:n relations. The Extension Builder will not create this automatically. It is of the type “Integer” and not required (since not all categories have parents).
Last but very much not least, we create a relation of the object to itself. The name of the relations is “subcategory” and it is of the type “m:n” – since this is what it’s all about. Also, we don’t want it to be a “inline” relation – we could not select existing categories that way. Then, we connect the “dot” from the relation to the dot of the domain by dragging a line from the dot at the bottom to the dot at the top left.
You will end up with this (Properties folded):
Now you can save your extension. You have now a new folder named after your extension key in your extension folder typo3conf/ext/yourextkey. We now have to update two things:
Open the file “ext_tables.sql” and scroll down to your mm table. We will need to add three fields and change the KEY fields:
We will also change the KEY definition and define the UID as the PRIMARY KEY and the pid as the parent KEY.
## Original fields: # KEY uid_local (uid_local), # KEY uid_foreign (uid_foreign) ## Changed fields for m:n PRIMARY KEY (uid), KEY parent (pid), ## New Fields for m:n uid int(10) NOT NULL auto_increment, pid int(11) DEFAULT '0' NOT NULL, tablenames varchar(255) DEFAULT '' NOT NULL
Now we change the subcategory TCA definition to allow for true m:n relations. Open the file “Category.php” at “Configuration/TCA” and find “MM” inside the “subcategory” configuration. We add two new definitions:
'MM_match_fields' => array(
'tablenames' => 'tx_nbomn_domain_model_category'
),
'MM_opposite_field' => 'category_mm',
You should also add a line inside the “add wizard” configuration to prevent adding new subcategories before the parent has been saved:
'notNewRecords' => 1,
That’s it for the subcategory configuration. It can now store relations to other categories. Now we need to setup the parent categories. We replace the whole “config” array of the “category_mm” field with the one of “subcategory”. Then we remove the “MM_opposite_field” entry:
That’s all. Now we have working Sub- and Parentcategories. You can now go to the Extension Manager and install your Extension. Then create a Sysfolder somewhere in your Pagetree and insert a new category.
After you save the category, you can create subcategories and also add new parent categories:
I hope, this helped you to create your own m:n relations with the Extbase Extension Builder. If you have any questions or suggestions, feel free to leave a comment. In case you like to take a look at my test extension – download nbomn – it’s also on GitHub.
Ps. On my way to this solution this thread was useful.
We see the world. Many of us. Not so Austin Seraphin. He can’t, can’t normally enjoy those millions of colors I often take for granted, can’t enjoy the stunning sight of the rising sun painting the horizon red, can’t usually gaze at the light of the stars or the deep blue of the ocean. He’s description of how he can see the world with the help of he’s iPhone is very moving.
The other night, however, a very amazing thing happened. I downloaded an app called Color ID. It uses the iPhone’s camera, and speaks names of colors. It must use a table, because each color has an identifier made up of 6 hexadecimal digits. This puts the total at 16777216 colors, and I believe it. Some of them have very surreal names, such as Atomic Orange, Cosmic, Hippie Green, Opium, and Black-White. These names in combination with what feels like a rise in serotonin levels makes for a very psychedelic experience.
I have never experienced this before in my life. I can see some light and color, but just in blurs, and objects don’t really have a color, just light sources. When I first tried it at three o’clock in the morning, I couldn’t figure out why it just reported black. After realizing that the screen curtain also disables the camera, I turned it off, but it still have very dark colors. Then I remembered that you actually need light to see, and it probably couldn’t see much at night. I thought about light sources, and my interview I did for Get Lamp. First, I saw one of my beautiful salt lamps in its various shades of orange, another with its pink and rose colors, and the third kind in glowing pink and red.. I felt stunned.
The next day, I went outside. I looked at the sky. I heard colors such as “Horizon,” “Outer Space,” and many shades of blue and gray. I used color queues to find my pumpkin plants, by looking for the green among the brown and stone. I spent ten minutes looking at my pumpkin plants, with their leaves of green and lemon-ginger. I then roamed my yard, and saw a blue flower. I then found the brown shed, and returned to the gray house. My mind felt blown. I watched the sun set, listening to the colors change as the sky darkened. The next night, I had a conversation with Mom about how the sky looked bluer tonight. Since I can see some light and color, I think hearing the color names can help nudge my perception, and enhance my visual experience. Amazing!
Read the whole Articel: My First Week with the iPhone