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) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Appropriate hook to add CSS for all pages in contribution flow?
Pages: [1]

Author Topic: Appropriate hook to add CSS for all pages in contribution flow?  (Read 606 times)

Chris Burgess

  • Ask me questions
  • ****
  • Posts: 675
  • Karma: 59
Appropriate hook to add CSS for all pages in contribution flow?
July 26, 2014, 06:10:08 pm
I wanted to modify CSS on a contribution flow (first page, confirm page, thanks page).

The first page is easy enough via hook_civicrm_formAlter() but I was confused that none of hook_civicrm_pageRun(), hook_civicrm_post_process() nor hook_civicrm_alterContent() was able to insert a CSS file using CRM_Core_Resources::singleton()->addStyleFile().

I ended up using hook_civicrm_config() which works fine, but it smells bad. Is there a hook I should be using that would handle this correctly?

The site in question is 4.3.x (they'll upgrade one day!) and I haven't tested the same behaviour against current versions.
@xurizaemon ● www.fuzion.co.nz

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Appropriate hook to add CSS for all pages in contribution flow?
July 28, 2014, 05:44:46 pm
Did you try using https://github.com/eileenmcnaughton/civicrm_developer to see what hooks run?

Chris Burgess

  • Ask me questions
  • ****
  • Posts: 675
  • Karma: 59
Re: Appropriate hook to add CSS for all pages in contribution flow?
July 28, 2014, 06:08:22 pm
Great pointer, should have considered that.

The answer is, none of them. The only hook civicrm_developer suggestd which I hadn't considered trying was buildAmount.

buildForm seems to be used on the confirm page, but the CSS doesn't get added if you call addStyleFile from there.

It's 4.3.7 so I'm not going to dig further, I'll revisit next time I fancy up a contribute form for a current release.
@xurizaemon ● www.fuzion.co.nz

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Appropriate hook to add CSS for all pages in contribution flow?

This forum was archived on 2017-11-26.