OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



How to format the text contents of e-mail templates?

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

How to format the text contents of e-mail templates?

Postby yaliang » Wed Aug 02, 2006 8:00 am

Dear Friends:

Currently, I'm editing the e-mail templates. I wonder is it possible to format the contents of text? For example, I want to high light the reviewDueDate with HTMLtags, such as
Code: Select all
<strong>{$reviewDueDate}</strong>
However, it doesn't work. In the received e-mail, an exmaple of the following message was shown:
Code: Select all
The review itself is due <strong>2006-08-30</strong>.

Please give me your suggestions. Thank you very much :D
yaliang
 
Posts: 82
Joined: Tue Jul 11, 2006 1:11 am

Postby asmecher » Wed Aug 02, 2006 10:47 am

Hi Yaliang,

OJS sends emails in plain text; to configure it to send HTML messages, you'll need to change the content type in classes/mail/Mail.inc.php and you'll also need to modify all of OJS's email templates to use HTML. (If you only need to send one or two email messages in HTML, the quick-and-dirty solution would probably be hard-coding certain messages to use HTML.)

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 8851
Joined: Wed Aug 10, 2005 12:56 pm

Postby yaliang » Fri Aug 04, 2006 1:50 am

Dear Alec:

Thanks for your explanations. I tried to edit the template as a HTML file, however, it was still received as a plain text. Could you tell me how to try the quick-and-dirty solution?

On the other hand, I have a question in using the "Prepared Emails". There are 53 e-mail templates. In default setting, they are displayed in three pages (with Maximal 25 files on one page). While I select one template which is not shown on the first page, after I edited and clicked the save button, the web page always went back to the first page. I had to click the ">>" to open the second page for editing the relative templates. Is there any method to let the webpage go back to the previous list? Or could all of the templates shown in one page?

Best regards,

Yaliang
yaliang
 
Posts: 82
Joined: Tue Jul 11, 2006 1:11 am

Postby asmecher » Fri Aug 04, 2006 10:41 am

Hi Yaliang,

You can change the number of items to appear on one page at the bottom of Journal Setup page 5; I'd suggest temporarily increasing this value, editing the emails, then returning it to its default value.

The "quick-and-dirty" solution will require a little bit of PHP programming. I'd suggest an approach like the following:
  • Add functions called getContentType and setContentType to classes/mail/Mail.inc.php; these will store the content type value in a class member variable called contentType.
  • In the constructor for the Mail class, setContentType('text/plain');
  • In Mail.inc.php, find where the class uses "text/plain" (there are two places) and use instead the getContentType function.
  • Find where the specific mail templates that you want to use HTML for are instantiated in OJS; you should be able to find this by searching the code for the email key (e.g. REVIEW_REQUEST). After the message $email is instantiated, do $email->setContentType('text/html');
This will take some familiarity with PHP; I hope this makes sense.

Regards,
Alec Smecher
Open Journal Systems Team

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 8851
Joined: Wed Aug 10, 2005 12:56 pm

Postby yaliang » Mon Aug 07, 2006 2:49 am

Dear Alec:

Sorry, I have another question about editing the "Prepared Emails". Among the default templates, the {$editorialContactSignature} are frequently used as the Signature shown in the end of the emails. However, in my case, the {$editorialContactSignature} refers to the Journal manager (in Journal SetUp - Step 1). Sometimes, it doesn't make sense to attach that Signature in the e-mail. For instance, when an Editor assigns a submission to a Section Editor (with the EDITOR_ASSIGN template), the Signature should be the Editor's Name, rather than the {$editorialContactSignature}. The problem is also existed in the REVIEW_REQUEST template (from Section Editor to Reviewer), the Section Editor's Name should be displayed in the signature not the {$editorialContactSignature} in default.
Is it possible to modify the Signature to display the correct Name? How could I do that?
At the same time, if I can modify the signature name, is it possible to display the sender's address in the out going e-mail?
Thanks for your help and time :D

Best regards,
Yaliang
yaliang
 
Posts: 82
Joined: Tue Jul 11, 2006 1:11 am

Postby asmecher » Tue Aug 08, 2006 8:53 am

Hi Yaliang,

This type of customization will require some knowledge of PHP; find the email message you need to customize the behavior of by searching for it in dbscripts/xml/data/locale/en_US/email_templates_data.xml and finding its email_key (e.g. REVIEW_REQUEST). Now search the OJS code for REVIEW_REQUEST (e.g. fgrep -l REVIEW_REQUEST `find . -name \*.php` on a *NIX machine) , and you'll find that it's referenced in the file "classes/submission/sectionEditor/SectionEditorAction.inc.php". This is where all the recipients and most of the replacement variables (e.g. {$reviewerUsername}) are configured.

There's some discussion of the email API in the OJS Technical Reference, available at http://pkp.sfu.ca/ojs/OJSTechnicalReference.pdf.

If you don't have PHP expertise on hand, a simple way to standardize the emails in the way you suggest is to include instructions in the email templates themselves -- for example, leave the text [EDITOR'S NAME HERE] in the email, where the editor will notice and replace it before sending.

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 8851
Joined: Wed Aug 10, 2005 12:56 pm

Postby yaliang » Tue Aug 08, 2006 9:30 am

Dear Alec:

Thanks for your explanations. I'll try it.
I think there might be a simple way to show the correct signature name. Since the e-mail will be sent while the specific user login and execute some actions (e.g. an editor assign a reviewer and send the Review_REQUEST e-mail), a simple way to show the correct signature name might be applying the user's full name. In the OJSTechnicalReference, the "=> $user>getFullName()" function could be a solution for that.
Is it correct? Could you give me some hits to try it?

Best regards,

Yaliang
yaliang
 
Posts: 82
Joined: Tue Jul 11, 2006 1:11 am

Postby asmecher » Tue Aug 08, 2006 9:41 am

Hi Yaliang,

Yes, this would be a good approach. You'll need to add the current user's name to the variable list for the email -- that is, add the following key/value pair to the array used in the $email->assignParams(...) call:
Code: Select all
'currentUserFullName' => $user->getFullName()
Once this is finished, if you use the token {$currentUserFullName} in an email template, it'll be replaced by the user's full name before the email is composed. (If you want to make this variable available in all emails, you might consider adding it in classes/mail/MailTemplate.inc.php in the assignParams function.)

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 8851
Joined: Wed Aug 10, 2005 12:56 pm

Postby yaliang » Wed Aug 09, 2006 3:44 am

Dear Alec:

Many thanks to your help.
In the Mail.inc.php, I found that the getContentType() and setContentType($contentType) were originally existed. While using the "quick-and-dirty" solution to change the e-mail type (plain text or HTML), it only needs to add the [ $email->setContentType('text/html'); ] for the REVIEW_REQUEST. It's very easy.
Also, I'll need to edit the e-mail templates by adding the tags in the contents. Although the contents are shown in the dbscripts/xml/data/locale/[localeName]/email_templates_data.xml file, unfortunately, the modifications made on the xml file do not change the default contents of the e-mail templates. The data seems to be saved in the MySQL database rather than the XML file.

Since it's much easier to edit the contents with the XML file, I wonder that is there any method I could update the database with the edited XML file?

Thanks and regards,

Yaliang
yaliang
 
Posts: 82
Joined: Tue Jul 11, 2006 1:11 am

How to modify the Journal's Signature in sending e-mail?

Postby yaliang » Wed Aug 09, 2006 11:12 pm

Dear Alec:

The "quick-and-dirty" solution for changing the ContentType (plain text v.s. HTML) was almost done. But there is a small question I wish you could give me suggestions to fix the problem.
In the end of the mail sent to a reviewer, there is a signature of the Journal, such as Journal of XXX http://www.JXXX.org, which is defined in SetUp 1. While the contentType was set as text/HTML, the Journal's Signature was sent as string without break lines (<br>).
Could you tell me what's the variable and in which file I could modify the content? Thank you very much :D

Best regards,

Yaliang
yaliang
 
Posts: 82
Joined: Tue Jul 11, 2006 1:11 am

Postby asmecher » Thu Aug 10, 2006 10:01 am

Hi Yaliang,

Look in classes/mail/MailTemplate.inc.php in the send function; the signature is fetched with the following snippet:
Code: Select all
$journal->getSetting('emailSignature')
If you replace that with the following snippet:
Code: Select all
str_replace("\n", "<br/>\n", $journal->getSetting('emailSignature'))
...new-line characters will be translated into HTML break tags. (You'll probably want to check that the content type is text/html before doing this.)

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 8851
Joined: Wed Aug 10, 2005 12:56 pm

Postby yaliang » Tue Aug 15, 2006 12:43 am

Dear Alec:

Great Solutions! Thank you very much :)

Best regards,

Yaliang
yaliang
 
Posts: 82
Joined: Tue Jul 11, 2006 1:11 am


Return to OJS Technical Support

Who is online

Users browsing this forum: Google [Bot] and 1 guest