Answers.Body: <p>The simple answer to &quot;Can I use the CRM directory that is auto-created by civix to <strong>easily</strong> store custom versions of existing CiviCRM PHP files?&quot; is no, not <em>easily</em>.</p>
  <p>While it can be made to work, if you just use a modified copy to replace the core file, then you have to keep your file in sync after every upgrade, which is <strong>not</strong> fun. So yes it takes extra work with a hook etc but then you don't have to keep updating your copy of the file. Also using modified copies of core files would make your extension ineligible for automatic distribution with civi if you ever wanted to do that.</p>
  <p>In this specific case (pun intended) for the activity list, it maybe is a bit more difficult than it could be because of the mix of many technologies used for that table.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-15T11:36:46.273Z
Answers.Text: Is there a reason why this solution *has* been kept with templates? Are templates not being changed during updates, or not so regularly?
Answers.UserDisplayName: emma
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-15T13:45:44.670Z
Answers.Text: I don't fully understand the question but core templates _do_ change regularly.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-17T08:53:53.917Z
Answers.Text: Maybe my question would have been more suitable under Aidan's answer, I see now. I refer myself to "Overriding core files was how we used to make changes until collectively we figured out that was storing up trouble for the future." -> Why does that not apply to templates? 
  It is more of a curiosity question though.
Answers.UserDisplayName: emma
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-17T14:09:00.937Z
Answers.Text: It does apply to templates, for the same reason as .php and other files. Use [hooks](https://docs.civicrm.org/dev/en/latest/hooks/) in your extension instead, which will avoid problems when you upgrade. The difficulty with using hooks for the activities list is that the activities list is designed in a way that's hard to work with so I don't have a good answer for that problem specifically.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-04T15:21:13.383Z
Answers.LastActivityDate: 2021-01-04T15:21:13.383Z
Answers.UserDisplayName: Demerit
Answers.Body: <p>Overriding core files was how we used to make changes until collectively we figured out that was storing up trouble for the future.</p>
  <p>Another possibility is that if you think this is likely to be a small, useful improvement for most users of this aspect of CiviCRM then you could propose it as a change for core - go <a href="https://lab.civicrm.org/dev/core/-/issues/new" rel="nofollow noreferrer">here</a> and use the 'improvement' template.  If that is agreed then submit your changes as a PR.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-07T11:10:26.963Z
Answers.Text: Thank you. To estimate if that could be sufficient for our specific problem: Do you know how long it would approximately/usually take for the changes to be put in place (if agreed)? This information could be useful to know if we need to work on a custom solution in parallel.
Answers.UserDisplayName: emma
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-07T12:10:34.253Z
Answers.Text: The release process is documented [here](https://docs.civicrm.org/dev/en/latest/core/release-process/) A new version has just been released so we are at the start of the cycle.  Once you submit your PR some checks run automatically that need to pass and it will be reviewed.  How long review takes varies a lot depending on the complexity of the change and interest/availability of reviewers but for a small change it can be a few days (even hours).  If your change were merged this month, it would be in the Feb RC and then the March release.
Answers.UserDisplayName: Aidan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-07T12:12:27.490Z
Answers.Text: ... and once it is merged, you can apply it locally to your site knowing it will part of the official release in a month or two.
Answers.UserDisplayName: Aidan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-05T11:04:27.903Z
Answers.LastActivityDate: 2021-01-05T11:04:27.903Z
Answers.UserDisplayName: Aidan
Body: <p>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 <code>View</code>, <code>Edit</code> and <code>More</code> links, but in a separate column together with their filename, for a clearer view.</p>
  <p>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 <code>sites/default/files/civicrm/ext/extensionname/templates/Case/Form/templatename.tpl</code>. The path where the original template lies is <code>sites/all/modules/civicrm/templates/CRM/Case/Form/</code>.</p>
  <p>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.</p>
  <p>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 <code>sites/default/files/civicrm/ext/extensionname1/CRM/extensionname2/path/to/example/example.php</code>, and they will simply be called instead of their original CiviCRM &quot;sister file&quot;?</p>
  <p>In this example, <code>extensionname1</code> stands for the name I gave to the extension while creating it with <code>civix generate:module</code> (here: <code>de.company.activities-column-for-documents</code>) and <code>extensionname2</code> stands for the extension's 'given name' from info.xml (here: <code>ActivitiesColumnForDocuments</code> when info.xml contains <code>&lt;file&gt;activities_column_for_documents&lt;/file&gt;</code>).</p>
  <p>I came up with this idea after reading <a href="https://docs.civicrm.org/dev/en/latest/extensions/structure/" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/extensions/structure/</a> 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 <code>Case.php</code> to <code>CRM_ActivitiesColumnForDocuments_Case.php</code>.</p>
  <p>The only other related thread I could find was <a href="https://civicrm.stackexchange.com/questions/11629/how-to-create-an-extension">How to Create an extension?</a> but I didn't find it helpful here.</p>
  <p>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?</p>
  <p>Any hints are appreciated :) If I can successfully create the extension, I will of course publish it here.</p>
  
Tags: <extension><civix>
Title: Creating extension with civix: How to use CRM dir?
ThreadText: # Creating extension with civix: How to use CRM dir?
  
  (Asked by: username_0 on 2021-01-04)
  
  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?](https://civicrm.stackexchange.com/questions/11629/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.
  
  **Tags:** extension, civix
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2021-01-05. Score: 4 | Accepted answer
  
  Overriding core files was how we used to make changes until collectively we figured out that was storing up trouble for the future.
  
  Another possibility is that if you think this is likely to be a small, useful improvement for most users of this aspect of CiviCRM then you could propose it as a change for core - go [here](https://lab.civicrm.org/dev/core/-/issues/new) and use the 'improvement' template. If that is agreed then submit your changes as a PR.
  
  > **Comments:**
  > **username_0**: Thank you. To estimate if that could be sufficient for our specific problem: Do you know how long it would approximately/usually take for the changes to be put in place (if agreed)? This information could be useful to know if we need to work on a custom solution in parallel.  
  > **username_2**: The release process is documented [here](https://docs.civicrm.org/dev/en/latest/core/release-process/) A new version has just been released so we are at the start of the cycle.  Once you submit your PR some checks run automatically that need to pass and it will be reviewed.  How long review takes varies a lot depending on the complexity of the change and interest/availability of reviewers but for a small change it can be a few days (even hours).  If your change were merged this month, it would be in the Feb RC and then the March release.  
  > **username_2**: ... and once it is merged, you can apply it locally to your site knowing it will part of the official release in a month or two.  
  
  ---
  
  ### Answer by username_1 on 2021-01-04. Score: 3
  
  The simple answer to "Can I use the CRM directory that is auto-created by civix to **easily** store custom versions of existing CiviCRM PHP files?" is no, not *easily*.
  
  While it can be made to work, if you just use a modified copy to replace the core file, then you have to keep your file in sync after every upgrade, which is **not** fun. So yes it takes extra work with a hook etc but then you don't have to keep updating your copy of the file. Also using modified copies of core files would make your extension ineligible for automatic distribution with civi if you ever wanted to do that.
  
  In this specific case (pun intended) for the activity list, it maybe is a bit more difficult than it could be because of the mix of many technologies used for that table.
  
  > **Comments:**
  > **username_0**: Is there a reason why this solution *has* been kept with templates? Are templates not being changed during updates, or not so regularly?  
  > **username_1**: I don't fully understand the question but core templates _do_ change regularly.  
  > **username_0**: Maybe my question would have been more suitable under username_2's answer, I see now. I refer myself to "Overriding core files was how we used to make changes until collectively we figured out that was storing up trouble for the future." -> Why does that not apply to templates?  It is more of a curiosity question though.  
  > **username_1**: It does apply to templates, for the same reason as .php and other files. Use [hooks](https://docs.civicrm.org/dev/en/latest/hooks/) in your extension instead, which will avoid problems when you upgrade. The difficulty with using hooks for the activities list is that the activities list is designed in a way that's hard to work with so I don't have a good answer for that problem specifically.  
  
  ---
  
  