Change canvas template with hook

So I want to change the template for creating new thirdparty contact. However, the documentation on the wiki is not very specific so I’ve decided to try and change the canvas via hook.

In my module, I have created following folder structure:

/mymodulefolder/canvas/contact/tpl/

and inside I’ve copied the original files contactcard_create.tpl.php, contactcard_edit.tpl.php and contactcard_view.tpl.php

This is the code I have so far, but it’s not working:

    public function doActions($parameters, &$object, &$action, $hookmanager)
    {
        global $conf, $user, $langs;
        $error = 0; // Error counter

        if (in_array('contactcard', explode(':', $parameters['context']))) {
            if ($action == 'create') {
                $objcanvas = null;
                $canvas = null;
                require_once DOL_DOCUMENT_ROOT . '/core/class/canvas.class.php';
                $objcanvas = new Canvas($this->db, $action);
                $objcanvas->getCanvas('extendedthirdparty', 'contactcard', $canvas);
            }
        }

        if (!$error) {
            return $objcanvas;
        } else {
            dol_print_error($this->db);
            return -1;
        }
    }

Any help appreciated.

So after some browsing in the French forum with automatic translation, as far as I understood using canvas is not recommended. They are not depreciated yet, but their development is abandoned. Instead, the better option is to “replace” the tab with my own.

Also, how to replace all the links to the default card.php to show my custom template?

@eldy can you confirm I’ve understood this correctly?

I confirm that the future of “canvas” feature is not clear.
So replacing the tab with yours seems a better choice for future.

Thanks. And where in the wiki I can see how to make my tab appear first and change all default links? I need to make custom template for /contact/card.php. If I click on the tab it loads my file, but all other links lead to default card.php