Jeff VIP
Total posts: 745
01 Dec 2014 05:09

Hi,

I would like to know how to override fields/email/email.php in order to change the format of the emails and to alter the success and error messages. I have tried copying email.php to mytemplate/html/com_cobalt/fields/email/email.php, but that didn't work.

Best regards, Jeff

Last Modified: 05 Dec 2014


Konstantin
Total posts: 1,113
01 Dec 2014 06:25

I think you can change the success and error messages by overriding language variable, translate it as you wont. Don't understand what is emails format.

In general you can't overide a main field file. All what you can do it's copy this field and create your own field.


Jeff VIP
Total posts: 745
01 Dec 2014 10:02

I was afraid you would say that ;-)

Konstantin I think you can change the success and error messages by overriding language variable, translate it as you wont. Don't understand what is emails format.

I use a YooTheme template. Cobalt email alert messages are generated in a new iframe. Basically it looks awful with no formatting. The only way I can change that is by overriding email.php

Emails sent by the email field are very basic with poor formatting. I want to change that too.

If I copy the email field, which files/variables do I have to rename? What about the js files, do I have to rename them or can I just refer to the original js files?


Konstantin
Total posts: 1,113
01 Dec 2014 11:04

You must rename all files which has name 'email.php'. Rename class name in this file 'email.php', and change atributes in xml file.


Sergey
Total posts: 13,748
02 Dec 2014 03:11

In iframe it use URL with &tmpl=component. So all you need is include required styles in /templates/[template_name]/component.php


Jeff VIP
Total posts: 745
02 Dec 2014 06:56

Konstantin You must rename all files which has name 'email.php'. Rename class name in this file 'email.php', and change atributes in xml file.

Thank you Konstatin, I've successfully made a copy of the email field. I had to add a language .ini file though....

Sergey In iframe it use URL with &tmpl=component. So all you need is include required styles in /templates/[template_name]/component.php

Thanks Sergey, but would that also affect the style of a printed page?


pepperstreet VIP
Total posts: 3,837
02 Dec 2014 10:06

Jeff Thanks Sergey, but would that also affect the style of a printed page?

In general, you can use different CSS for screen and print results. You can add media="screen" or media="print" to the stylesheet link.

Since you have a special email field and full control over the actual iframe/URL...

  • You may also add an additional URL parameter to that link, then fetch and use that parameter value in the component.php for conditional output.
  • Or create your own "component.php" file, just rename it to your liking and use that file specifically for your email purposes. e.g. componentemail.php Change the name in the iframe/URL accordingly: &tmpl=componentemail

Jeff VIP
Total posts: 745
03 Dec 2014 01:27

Hi pepperstreet,

some great advice here.

Thanks!


Sergey
Total posts: 13,748
04 Dec 2014 04:37

The other way round is to change email field template only and change &tmpl=component to &tmpl=email and then create email.php in your template root.

This way printed version of the page will not be affected.


Jeff VIP
Total posts: 745
05 Dec 2014 02:02

Sergey The other way round is to change email field template only and change &tmpl=component to &tmpl=email and then create email.php in your template root.

Oooh,

That's even a better idea :-)

Thanks Sergey!

Powered by Cobalt