Forums / Cotonti / Support / Can I use structure for a plugin?

Klaestrup
#1 2012-09-04 20:03

First I have to say, that Cotonti is so awesome, nice, clean and flexible...! smiley

I want to use structure/categories in a plugin. Is this possible, or do I have to make a module to use the structure function?

diablo
#2 2012-09-04 22:05

what exactly are you gonna do with this plugin? you can use the page structure for almost anything.

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
Trustmaster
#3 2012-09-05 09:03

Structure is where we can draw the line between modules and plugins: modules can define their own structure, plugins use the structure of existing modules. Technically this limitation is not so strict and you might be able to do that in a plugin, but still it is recommended to make a module instead.

As an example, see how Forums module tells the system that it wants its own structure: forums.structure.php. That file registers it in Administration / Structure section. To use structure of your module in the module's code, just use the global:

$structure['module_code']['category_code']

 

May the Source be with you!
Klaestrup
#4 2012-09-05 13:36

I will make a repair log, where the technician can create a observasation or a repair. I don't know exactly what info I need in the registrations, but I think it will include some checkboxes, dropdowns and textarea, maybe the possibility for others to post comments. I'm not sure if I can use pages for this type of task, or what will you prefer???

Trustmaster
#5 2012-09-05 13:49

Are log entries categorized?

If you need to decide whether to use pages or custom database tables, here are helper questions:

  • Is there a free-form text with markup?
  • Does each entry have a unique title?
  • Are the entries categorized as a tree?
  • Do you want to connect comments or other page-specific plugins to each entry?

If all 4 answers were yes, then you should better use pages + extra fields. If you answered no to most questions, especially the first two, then you'd better create your own data model.

May the Source be with you!
Klaestrup
#6 2012-09-05 14:03

Yes, the log shall be categorized. Actually I don't think the entries will have a title at all (so no unique page title), but a ID, a repair/problem description and action taken, and to choose status (Not fixed / Fixed etc.).

No markup, just plain text fields.

The ability to write comments would be good, so others can help with a unfixed problem.

Trustmaster
#7 2012-09-05 16:32

Then I'd go for a custom module. Comments have the API to be connected to anything, so not a big problem.

May the Source be with you!
Klaestrup
#8 2012-09-05 18:54

OK, I will give it a try!

GHengeveld
#9 2012-09-05 20:45

If you want to streamline development and PHP 5.3 is available, you could consider using cot-factory with CotORM.