2

I'm wanting to add content to a region in EventInfo.tpl. The Docs give this function as an example, but do not clarify exactly where this "CRM_Core_Region::instance('page-body')->add" method is called from.

  CRM_Core_Region::instance('page-body')->add(array(
      'markup' => '<p>Congratulations! You won the lottery!</p>',
  ));

Can I call this method from within a theme file like functions.php? Is there a predefined directory where custom region code should live?

2 Answers 2

3

You need to implement it in hook, if you are looking to add content on event info page than you will need to implement it in pageRun() hook

2
  • Do I need to make an extension that uses the "pageRun" hook or can I declare the hook elsewhere like in my theme's functions.php file?
    – dsmith63
    Commented Dec 17, 2021 at 17:10
  • You create an extension or use add_filter in your plugin or theme Commented Dec 18, 2021 at 12:45
3

Solution found: https://docs.civicrm.org/dev/en/latest/hooks/usage/wordpress/

add_filter('civicrm_pageRun', 'addJoinLink', 10, 4 );

function addJoinLink() {
    CRM_Core_Region::instance('event-page-eventinfo-actionlinks-top')->add(array(
        'markup' => '<p>Congratulations! You won the lottery!</p>',
    ));
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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