I'd like to replace the default logo in my email templates ({$resourceBase}/i/civi99.png) with a URL that points to a different location where the custom logo won't be overwritten by updates. I can do that by directly editing the template to point to https://www.mydomain.com/images/logo.png for example, but I'd like to avoid asking customers to edit the templates, which requires programming skills. Instead, I'd like to tell them to put their logo in a magic folder where it will be picked up if it exists.

Probably [civicrm.files] would be a suitable location but I can't work out how to expand that in a smarty template.

I tried {crmSetting name="imageUploadURL" group="URL Preferences"} but that returns "[civicrm.files]/persist/contribute/" which doesn't expand the variable.

I also tried {crmResURL ext=civicrm} but that just gives "/wp-content/plugins/civicrm/civicrm/" which is not a complete URL and in any case points to a directory that will get overwritten by updates (yes I'm on WordPress).

I haven't yet found where $resourceBase is set but something equivalent that returns https://www.mydomain.com/wp-content/uploads/civicrm would be good. I think I can only create that new variable by writing an extension though, which is a lot of bother if there's a better way. I would have expected the root URL of the installation to be in the settings or global variables somewhere and accessible from smarty but I can't find it.

A possibly related problem is that I'd also like to retrieve information like the date of a contribution from the database and display that in an email. Again, I can see that information is put in a smarty variable in Invoice.php for example, but the format is wrong (American, comma in wrong place) and my hunch is the information should be accessible some other way through the API. But if so I can't find it.

I've spent several hours on this (even bought the book) and I'm still struggling to find any information on how to create or use variables like [civicrm.files] in general, and in smarty in particular. Can any one help with either a specific or a general solution?

Update: I've found a partial solution to the logo path problem. {$smarty.server.SERVER_NAME} will get the name of the "server", in a format like "www.mydomain.com". By sticking "https://" in front and "/wp-content/uploads/civicrm" at the end you can make a good guess at where civicrm.files is likely to be on a WordPress installation. But it's only a guess.

2 Answers 2


You can use

{crmResURL ext='civicrm.files'}
  • Thanks, I didn't know that (where's it documented, do you know?). However it returns a server path not a URL so it's not much use in an email or for generating a PDF. Aug 23, 2017 at 2:22
  • I find it in the code, on the place were the help screen is generated github.com/civicrm/civicrm-core/blob/… . But in the first try I had the wrong screen. It must be crmResURL. I updated the answer. Aug 23, 2017 at 7:00
  • Brilliant, I just guessed it myself and came back here and you had already answered. I've marked this as the answer, thanks very much @Kainuk! It's a shame such a little thing is so hard to find though. Aug 23, 2017 at 13:19

Details on the Smarty CiviCRM interface are here: https://docs.civicrm.org/dev/en/master/api/interfaces/#smarty-api-interface

However, this seems like overkill for handling the date issue. I suspect that this can be fixed by changing the currency settings (Administer menu » Localizations » Languages, Currency, Location). If this does NOT fix your issue, that's a bug and should be reported.

As for the logo issue - I don't think there's a way to do what you're asking without an extension. Fortunately, it should be a very small extension, maybe 5-10 lines of code using hook_civicrm_alterMailParams. Best yet, you don't have to deal with Smarty :-\

  • Thanks, that Smarty interface link is helpful. I confirm that the localization settings don't fix the date format issue and I can see the format is hard coded in Invoice.php, so I will raise a bug report. I may have found a partial solution to the logo issue, see below. Aug 15, 2017 at 17:21
  • Also note that you can add a {debug} token to your Smarty template to see all variables. Aug 15, 2017 at 19:17
  • {debug} has no effect - I assume because javascript doesn't run in a PDF file? Aug 23, 2017 at 2:19
  • Hmm, the docs here docs.civicrm.org/dev/en/master/framework/templates say you need to enable debugging first at Administer > Configure > Global Settings > Debugging. That tree doesn't exist but I found a similar setting at Administer > System Settings > Debugging and Error Handling. But it doesn't make any difference. I'm lost in a maze of twisty little passages. Aug 23, 2017 at 13:34

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.