1

Joomla/CiviCRM.

Neophyte Warning!

I've written a triggerinfo hook as per this article.

What I don't understand is where on the file system is one supposed to place the PHP file so that when one requests a trigger rebuild, the file will be found, and so that when an upgrade occurs the file will not be overwritten.

Can someone help me please?

Regards Simon

1

You should create an extension. See the instructions for civix. One thing that civix can do is generate a skeletal extension. After running civix generate:module you would add your code to the main php file in your new extension. See also Extension Structure.

  • Thanks Andrew for your answer. Since all my triggerinfo php script does is call a MySQL procedure that I have written in response to an insert or update on the address table, surely an extension is overkill? – Simon Greener Oct 9 '17 at 0:18
  • The SQL in the triggerInfo PHP script contains this: $sql = "IF (NEW.state_province_id IS NOT NULL AND (NEW.geo_code_1 IS NOT NULL AND NEW.geo_code_1 <> 0.0) AND (NEW.geo_code_2 IS NOT NULL AND NEW.geo_code_2 <> 0.0)) THEN CALL myfunc(NEW.ID,NEW.state_province_id,NEW.geo_code_1,NEW.geo_code_2); END IF; ";` – Simon Greener Oct 9 '17 at 0:26
  • Yes but if you want to keep your code between upgrades then an extension is the best way of doing it. It's not hard to make a simple extension with civix. – Andrew Thompson Oct 9 '17 at 3:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.