OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Question about variables used in email 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.

Question about variables used in email templates

Postby cewing » Wed Jun 27, 2007 11:40 am

I have been asked to alter the email templates for a journal in OJS. Looking at the existing template code, I see that there are variables present for things like {$reviewerName} and other bits that are replaced at write-time. I'd like to find a list of all the available variables, and am also wondering if there is a way to set up new variables.

For example, to increase review request response rates, my journal's editor would like to include the user_id of the reviewer to help them respond more easily. He'd also like to replace the call to {$reviewerName} at the top of a template, which returns the full name of the reviewer, with a varialbe that returns only the last name.

Any suggestions?
cewing
 
Posts: 16
Joined: Tue Jun 26, 2007 12:09 pm

Postby asmecher » Thu Jun 28, 2007 9:57 am

Hi cewing,

Different variables are available to each email template, so the location of the code you'll need to change depends on the email template you're working with. For example, the email template called REVIEW_REQUEST (which is the reviewer request email, sent to a potential reviewer by an editor) is implemented in classes/submission/sectionEditor/SectionEditorAction.inc.php. On a *NIX platform, you can find the relevant code's filename given the name of the template using a command line like:
Code: Select all
fgrep -l REVIEW_REQUEST `find . -name \*.php`
Now, find the code where the email template is created by searching that code for the template name:
Code: Select all
$email = &new ArticleMailTemplate($sectionEditorSubmission, $isEmailBasedReview?'REVIEW_REQUEST_ATTACHED':($reviewerAccessKeysEnabled?'REVIEW_REQUEST_ONECLICK':'REVIEW_REQUEST'), null, $isEmailBasedReview?true:null);
(Usually it's a little simpler, but the various review modes available mean that the template might be one of a few different options.)

Now look further down in the same body of code for the variable assignment, which will always look something like:
Code: Select all
$paramArray = array(
        'reviewerName' => $reviewer->getFullName(),
        'weekLaterDate' => $weekLaterDate,
        'reviewDueDate' => $reviewDueDate,
        'reviewerUsername' => $reviewer->getUsername(),
        'reviewerPassword' => $reviewer->getPassword(),
        'editorialContactSignature' => $user->getContactSignature(),
        'reviewGuidelines' => $journal->getSetting('reviewGuidelines'),
        'submissionReviewUrl' => $submissionUrl,
        'abstractTermIfEnabled' => ($sectionEditorSubmission->getAbstract() == ''?'':Locale::translate('article.abstract')),
        'passwordResetUrl' => Request::url(null, 'login', 'resetPassword', $reviewer->getUsername(), array('confirm' => Validation::generatePasswordResetHash($reviewer->getUserId())))
);
These are a series of name => value pairs defining what variables are available. If you want to add a new variable to the template's available set, simply add it here and then reference using the {$variableName} syntax.

Regards,
Alec Smecher
Open Journal Systems Team
---
Don't miss the First International PKP Scholarly Publishing Conference
July 11 - 13, 2007, Vancouver, BC, Canada
http://ocs.sfu.ca/pkp2007/
asmecher
 
Posts: 7737
Joined: Wed Aug 10, 2005 12:56 pm

Thanks a ton

Postby cewing » Thu Jun 28, 2007 10:05 am

Thanks,

that was exactly it. I noticed that the $reviewer object there seems to be an instance of the user class, so I should be able to add any parameters that I want that are available from that class, right?

On a related note, given that I'm making small but significant changes to the code base, what is the best practice for ensuring that those changes are preserved across system upgrades?

Thanks again,

Cris
cewing
 
Posts: 16
Joined: Tue Jun 26, 2007 12:09 pm

Postby asmecher » Thu Jun 28, 2007 10:45 am

Hi Cris,

Yes; in SectionEditorAction.inc.php, the Reviewer object will be an object of the User class. However, you can't simply assign the entire Reviewer object to the email template and then use e.g. {$reviewer->getFullName()} in the email template -- email templates can only contain simple variable replacements.

We distribute OJS upgrades in several formats, including as patches. When a new release comes out, I'd suggest following the patch-based upgrade method rather than the .tar.gz package; that will help you painlessly preserve modifications. I'd also suggest keeping a backup of your own modifications by generating a patch against the stock version of OJS you're using. Let me know if you need help with any of these.

This will be easier if you keep your modifications to contiguous blocks of code; that'll keep conflicts limited. The --dry-run option to the patch tool is also very useful; it'll let you see where conflicts will crop up without actually modifying any files.

Regards,
Alec Smecher
Public Knowledge Project Team
---
Don't miss the First International PKP Scholarly Publishing Conference
July 11 - 13, 2007, Vancouver, BC, Canada
http://ocs.sfu.ca/pkp2007/
asmecher
 
Posts: 7737
Joined: Wed Aug 10, 2005 12:56 pm


Return to OJS Technical Support

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 10 guests