CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Changing contribution page tpl by hook
Pages: [1]

Author Topic: Changing contribution page tpl by hook  (Read 2469 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Changing contribution page tpl by hook
August 05, 2013, 12:37:35 am
For a long time it has been possible to over-ride some tpls on a per event, per contribution page, per profile basis but we have a requirement to do it by another criteria (in this case contribution type). Is there a mechanism I'm not yet aware of to alter this by hook? If not I wonder if adding a hook into   function getTemplateFileName() { would make sense - I can tell that at least the page id is known by the time that function is called
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Changing contribution page tpl by hook
August 05, 2013, 12:55:21 am
Sounds like a useful and simple solution.

a workaround could be to alter the include path for the smarty templates and override the template based on your criteria.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Changing contribution page tpl by hook
August 05, 2013, 01:26:35 am
Yeah - although if the hook seems right I'll add it in 4.4 & backport it onto 4.2
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Changing contribution page tpl by hook
August 06, 2013, 02:04:41 pm
A hook sounds like a good idea. Personally, I think the hook should apply to every page (regardless of whether the page ordinarily uses the standard version of getTemplateFileName() or the overridden version). It would be fairly laborious to do that by invoking the hook from within getTemplateFileName() because there are about 30 classes which override getTemplateFileName(). The override idiom (eg https://github.com/civicrm/civicrm-core/blob/master/CRM/Event/Form/ManageEvent.php#L376 ) won't call the hook unless you update each overidden function.

I think it would be better to call the hook outside getTemplateFileName() - eg in spots like:

https://github.com/civicrm/civicrm-core/blob/8ef12e641c29ddfb6ea443c61ac323b71dbcdb4a/CRM/Core/Page.php#L158

There are probably a few more spots (eg CRM/Core/QuickForm/Action/Display.php) -- one would need to grep to find them all, but it should be a more manageable number (like 2-6).

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Changing contribution page tpl by hook
August 06, 2013, 02:24:37 pm
Ie. you are saying call it after the template is retrieved & you think there are less places?
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Changing contribution page tpl by hook
August 06, 2013, 02:47:46 pm
Yup

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Changing contribution page tpl by hook

This forum was archived on 2017-11-26.