Shared controllers?

I have read about Kirby controllers. It’s nice to have functions attached to a template.

Are there any shared controllers? What I mean is a controller that are used by more than one template.

An example:

A function to be put, for example in a controller.

function widget() {
    echo 'Do this in my sidebar';
}

…used by…

/blog/a-post
/blog/a-post2
/home

Home and blog are different template files. I could duplicate code or have it in a plugin. Should I not use controllers for shared functions?

A controller is always attached to a template by it’s name, so there is nothing like a shared controller. In that case I’d suggest to put those functions into a plugin.

1 Like

A solution to the problem:

http://forum.getkirby.com/t/shared-controller/1839