Custom Asset - Create Comments as an attribute


(Nic Hubbard) #1

I am working on a new custom asset (not ready to explain what it is quite yet :)). Once the asset is created, I would like to have the option of allowing comments to be added to the asset. These could just be normal Comment Assets that are created as children, BUT, I need to be able to create those comment assets from the Details Screen of my custom asset. (Possibly create them in a Comments Folder?) Also, I would like to be able to have all of the comments listed on the custom Assets details screen.


Could one of the devs point me in the right direction?



Thanks!


(Edison Wang) #2

A good way of doing it is finding similar code and recycling them.


To create the initial Comments folder, you can put the create folder code in _createAdditional() function of the custom asset. See form.inc



In the edit_interface_details.xml file define the paint and process function for the comment asset listing/creation interface. Place those functions in xxx_edit_fns.inc.

Also define lang_screen_details.xml locale file for the interface.



To list and create those comments, you will just use functions in Asset Manager class. Unless you want to write custom SQL.

e.g get all children comment assets of folder.

$GLOBALS['SQ_SYSTEM']->am->getChildren('folderid', 'comment');



You can also the code to create assets in form.inc, when it creates folder asset. But you probably don't need to set permission or set run level.





I don't know what else you want to know. Do you have any specific questions?


(Nic Hubbard) #3

[quote]
A good way of doing it is finding similar code and recycling them.



To create the initial Comments folder, you can put the create folder code in _createAdditional() function of the custom asset. See form.inc



In the edit_interface_details.xml file define the paint and process function for the comment asset listing/creation interface. Place those functions in xxx_edit_fns.inc.

Also define lang_screen_details.xml locale file for the interface.



To list and create those comments, you will just use functions in Asset Manager class. Unless you want to write custom SQL.

e.g get all children comment assets of folder.

$GLOBALS['SQ_SYSTEM']->am->getChildren('folderid', 'comment');



You can also the code to create assets in form.inc, when it creates folder asset. But you probably don't need to set permission or set run level.





I don't know what else you want to know. Do you have any specific questions?

[/quote]



Thanks, I have it working so that it creates a Comments folder as a child, as a TYPE_2 link, and also doesn't allow that folder to be deleted. I think I am find with figuring out the code, but is there anywhere in Matrix that I can see a UI example of how comments in an asset work? I thought that this feature was in workflow, but I can't find it, since I never really use it. I just wanted to see how Squiz did the layout of the fields, so I can make things standardized.



I might be back with some other questions too. :slight_smile:


(Edison Wang) #4

There is no existing backend UI for comments creating in Matrix.
You will have to design you own, and copy some UI elements from other assets. Like Form question/section creating UI, for example.


(Nic Hubbard) #5

[quote]
There is no existing backend UI for comments creating in Matrix.

You will have to design you own, and copy some UI elements from other assets. Like Form question/section creating UI, for example.

[/quote]



No worries. Thank you!