I want to create an extension for CiviCRM that will add an extra column for appended documents inside the activities list of a Case View. That is, when users have appended a document while creating an activity, that document will not be shown in one column together with the View
, Edit
and More
links, but in a separate column together with their filename, for a clearer view.
The changes I need to make contain six patches inside three PHP files, and one patch inside a template file.
I used civix to create an extension skeleton.
Then, it has been easy to make the adapted template file work by copying it into sites/default/files/civicrm/ext/extensionname/templates/Case/Form/templatename.tpl
. The path where the original template lies is sites/all/modules/civicrm/templates/CRM/Case/Form/
.
But now, I'm struggling with including the adapted PHP files. I know that hook functions exist and that I could try to find a suitable hook function for each of the six patches, but it seems a very complicated solution to me.
I wonder if there is a solution similar to the way templates can be included in extensions?
For example, is there a way to put all the PHP files inside a folder structure like sites/default/files/civicrm/ext/extensionname1/CRM/extensionname2/path/to/example/example.php
, and they will simply be called instead of their original CiviCRM "sister file"?
In this example, extensionname1
stands for the name I gave to the extension while creating it with civix generate:module
(here: de.company.activities-column-for-documents
) and extensionname2
stands for the extension's 'given name' from info.xml (here: ActivitiesColumnForDocuments
when info.xml contains <file>activities_column_for_documents</file>
).
I came up with this idea after reading https://docs.civicrm.org/dev/en/latest/extensions/structure/ where it sounds like you'd be able to do that, if you only follow the naming conventions (CRM_Myextension_...). Though, it didn't work, even though I renamed all my PHP files, e.g. from Case.php
to CRM_ActivitiesColumnForDocuments_Case.php
.
The only other related thread I could find was How to Create an extension? but I didn't find it helpful here.
Can I use the CRM directory that is auto-created by civix to easily store custom versions of existing CiviCRM PHP files? How? If not, what is the auto-created CRM directory for?
Any hints are appreciated :) If I can successfully create the extension, I will of course publish it here.