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) »
  • Un-themable output?
Pages: [1]

Author Topic: Un-themable output?  (Read 2519 times)

lentilsoup

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 6
Un-themable output?
January 19, 2009, 11:33:56 am
Hi folks,

I'm trying to apply a custom theme (supplied to me by the client's designer) to some of the forms in CiviCRM, and finding that in a lot of places the HTML isn't customizable -- i.e. the values passed to the Smarty templates are already HTML.

For instance, I need to wrap each contribution amount radio button and its label together in a div, but all the radio buttons and labels arrive at the template already in a single string of HTML, divided by <br> tags instead.

From what I can tell, this stuff is generated deep in the bowels of CiviCRM in the QuickForm code.  Am I missing something?  Is there somewhere else where I could intercept the rendering?

Thanks!

=======

EDIT: yes, it looks like some of the HTML I need to change is in QuickForm, and the rest is in the core CiviCRM code (e.g. CRM_Contribute_Form_Contribution_Main::buildAmount).  Is there any way to customize this stuff without creating an absolute maintenance nightmare?
« Last Edit: January 19, 2009, 05:08:45 pm by lentilsoup »

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Un-themable output?
January 19, 2009, 08:14:36 pm

most of the quickform elements are generated by html within QF and hence a bit hard to theme from smarty. You can potentially hack the PHP code to make it happen, but i suspect its non trivial (and you probably dont want to hack the code either)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

lentilsoup

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 6
Re: Un-themable output?
January 20, 2009, 11:29:03 am
No, I don't want to hack QuickForm, definitely.

What about classes like CRM_Contribute_Form_Contribution_Main?  If I were to subclass them, what would it take to get CiviCRM to call the subclasses?

That way one could override a couple of functions and adjust the HTML they construct and not have to worry about maintaining a complete personal fork of the core.

Thanks again!

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Un-themable output?
January 20, 2009, 12:38:11 pm
The buildAmount hook which has been added for v2.2 might give you what you want (allows you to modify or replace the amount structure in the Contribution and /or Event registration forms).

http://issues.civicrm.org/jira/browse/CRM-3810

General doc on hooks is here:
http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+hook+specification

The buildAmount hook hasn't been documented yet. If you think it will work for you and need help trying it out - probably best to get on IRC (or post back here).
Protect your investment in CiviCRM by  becoming a Member!

lentilsoup

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 6
Re: Un-themable output?
January 20, 2009, 12:41:42 pm
Thanks.  I'm concerned, though, that 2.2 won't be stable enough for a production site when we launch in 2 weeks -- given that it just hit alpha.  Is that a valid concern?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Un-themable output?
January 20, 2009, 05:20:25 pm

yes, 2.2 is still alpha but if you are willing to put up with a few issues and willing to upgrade on a regular basis, it should not be too bad :)

however, the buildAmount hook will not give you the needed functionality. The hook allows you to tailor the amounts and labels, but not the html output

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

lentilsoup

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 6
Re: Un-themable output?
January 20, 2009, 08:19:34 pm
Hm.  What I need to replace is actually just a little bit of the code it passes to QuickForm -- for instance on line 352 / line 376 of CRM/Contribute/Form/Contribution/Main.php:

Code: [Select]
$this->addGroup( $elements, 'amount', $title, '<br />' );
If I can replace that with something like:

Code: [Select]
$this->addGroup( $elements, 'amount', $title, '</div><div class="myclass">' );
it will go a long way towards being able to implement what I need WRT theming.  Is that something this hook would support?

Thanks!

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Un-themable output?
January 21, 2009, 06:40:20 am

The hook does not support that (as yet). You'll need to modify the code (and the tpl file to put in the first <div....> and last </div>). You should be able to create custom versions of both the php file and tpl file and hence avoid the hack (however u'll need to update it whenever u upgrade civicrm etc)

lobo

A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

lentilsoup

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 6
Re: Un-themable output?
November 04, 2009, 03:34:24 pm
In 3.0, one can work around this with the following template code (adjusting the markup as you desire):

Code: [Select]
{foreach from=$form.amount item=option key=k}
{if $k|is_integer || $k == "amount_other_radio"}
<li>
{$option.html}
{if $k == "amount_other_radio"}
{$form.amount_other.html|crmMoney}
{/if}
</li>
{/if}
{/foreach}

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Un-themable output?

This forum was archived on 2017-11-26.