[Plugin] Add Custom Field / Column to Project Board Columns


I was wondering if it is possible to develop a plugin that lets me add a custom field/column to my Columns on my Board in my Projects.

To make it a bit clearer I created some screenshots. The new fields I want to add are marked red.

I want to add an integer value to these columns. Therefore i need a new field when creating a custom column. These values wont be shown on the board. They will be used internally.

I am grateful for every pointers.

definitely possible. what part do you need help with? take a few moments to read the docs pertaining to plugin development, and then check out some plugins out there which add to the schema or utilize metadata. that should help provide enough information to then ask questions.

the docs:

a whole bunch of plugins to learn from:

Thanks for the quick reply.
Your hints helped me out.

I took a look at the documentation again and also inspected some plugins and found out:
- how to alter the columns table (Plugin Schema Migration)
- how to change the frontend (Template Override)

So… I now have my new custom field in the database and in my frontend. So far so good.

Whats still missing is the Model / Controller. I identified the methods in the code:

->getAllWithTaskCount (for the view project->columns)
->create (for the create dialog)

->save (for the create dialog)

I can change the source code of the main application and it works… but sadly I still dont understand how to alter these parts through my plugin.

How can i override these methods?
Can i use hooks for that? If so where can I find the name of the hooks and how would i got about it?

Thanks again.

I understand that its also possible to add custom fields using hooks… but i didnt quite understand how to do it for the column template. For example Template/Column/index.php.
Im using Template Override for now but it feels like hooks are the way to go? (Template Hooks?)
But … looking at the list of template hooks… I could not find the hooks for the columns (index & create):

You could do either, however, to use a hook, which doesn’t exist, would require you adding the hook to the core through a PR (or if its just you, add it to your core code to connect to it). A couple things to note, when a plugin overrides a model, in the event that 2 plugins are being used, and both override the same model, there will be an issue, as only 1 model will be overriden(unless you account for that in your code, you can see the accountabilities in plugin examples such as MetaMagik and Group_assign), if its just for you, I would simply override it. Personally, it could be argued both ways as to which is the best approach, if the hook exists, definitely use it, but if you have to make a PR to add a hook, then you have no backwards compatibility until its added. I have no qualms overriding anything.

Example of overriding a model:

If you are just adding to a function, and don’t want to upset the core model, extend the model using parent:: might be the most simplest way. i.e: Group_assign/NewMetaMagikSubquery.php at 2cc761e44b859e1c3b834ff8a684e2a7a75d2457 · creecros/Group_assign · GitHub

Controllers do not necessarily need to be, “overridden”, just called. So, you need to figure out how to call your controller, instead of the previous one. Generally, controllers are called in a template, so in this instance, using a hook won’t work for you, you will need to override the template to call your controller instead. I will continue to use MetaMagik as an example here:

Custom Controllers:

Calling these controllers:

The main thing to notice here, is the array when calling them, includes 'plugin' => 'MetaMagik'
And the namespaces of the controllers.

That helped a lot.
I extended the old model/controller and changed the functions. I did override the templates and called my new controller there. It is working without a problem.
Thanks again.

What do you mean by “PR”? I am not familiar with that acronym. Does it mean “Pull Request”?

What I am still concerned about are future kanboard updates. For example when one of the templates are changed in the maincode… I would have to update my plugin accordingly.

How often does that happen?

yes PR, pull request.

and yes, if the template you override is updated in kanboards main code, it would be appropriate to update yours as well. It’s something that happens, and something to consider, I haven’t experienced many of these, and generally don’t even notice unless someone points it out on my issue pages.