Table of Contents

You can add your own entries to the language file. You might do this, for example, if you are using multiple language files and want to create a customized comments template. In such a case you have multiple languages but can only put text directly into the template for one language. An example that comes to mind is a greeting in a guestbook.

It is always nice to hear from people that have visited so leave a comment, ask a question or just say hi.
Normally you would place such text in your html file above the TalkBack include. Example:
<p>It is always nice to hear from people that have visited so leave a comment, 
ask a question or just say hi.</p>
			
<?php require 'talkback/comments.php'; ?>
		

That works fine for users that have a single language site. But if your site is multi-language, the greeting is not translated because it is (1) not in the language file and (2) not inside the comments template. Read on to learn how you can rectify that.

First, add your greeting to each override language file (e.g. my-english.php and my-dutch.php). Create an entry using an entry name that won’t conflict with any other language file names. I suggest using the prefix “my_” (you can use underscores but not dashes in entry names).

$lang['my_greeting'] = "It is always nice to hear from people that have visited so leave a comment, ask a question or just say hi."

Then create a custom template by copying and renaming comments-display-tpl.php (e.g. my-comments-display-tpl.php). This prevents your changes from being overwritten if you upgrade to a new version of TalkBack. Add a new paragraph at the beginning of the template. Below is the beginning of the template, before you change it:

// +++++++++++++++++++++++++++++++++++++++++++++++
// Print the "Leave a comment" link
// +++++++++++++++++++++++++++++++++++++++++++++++
print "
<div id='tb-wrapper'>
   <p id='tb-comment-link'><a href='#tb-form-div'>{$lang['comdisplay6']}</a></p>"; 
And here is the template after you insert your greeting paragraph:
// +++++++++++++++++++++++++++++++++++++++++++++++
// Print the "Leave a comment" link
// +++++++++++++++++++++++++++++++++++++++++++++++
print "
<div id='tb-wrapper'>
   <p>{$lang['my_greeting']}</p>
   <p id='tb-comment-link'><a href='#tb-form-div'>{$lang['comdisplay6']}</a></p>"; 

{$lang['my_greeting']} tells PHP to insert that entry from the language file into the output HTML. Note the beginning and ending braces. They are necessary, you will get a PHP error if you omit them. Where you place it in the template is up to you. You could also place it above the tb-wrapper div.

Finally, instruct TalkBack to use the new template instead of the default template. Edit the filename for “Comments display template” via admin configuration maintenance.