Hi
I need to be able to customize these strings :
titlelandscape
titleletterportrait
titleletterlandscape
titleportrait
statementletterportrait,
statementlandscape
statementletterlandscape
statementportrait
How can it be done ?
1) Can i add in the certificate/mod_form in the definition function an element using addElement ? if so: How these lines can be record? wich lines of code must be added to accomplish this task ? these lines must be modified in the certificate/lib.php file ? if so: inside wich function ?
Thank´s in advance
These call lang strings from the certificate/lang/certificate.php file. They appear toward the bottom of the certificate/type/"typename"/certificate.php file.
They can be changed in both files to anything you want.
They can be changed in both files to anything you want.
Hi Chardelle
I need to customize them using the mod_form.php file and fields inside the database because two courses can have diferrent words as Declaration or Certificate and so on ...
This would be like the custom text, but this is custom title and statement instead of a lang string from certificate.php.
How can it be done ?
Thank´s
I need to customize them using the mod_form.php file and fields inside the database because two courses can have diferrent words as Declaration or Certificate and so on ...
This would be like the custom text, but this is custom title and statement instead of a lang string from certificate.php.
How can it be done ?
Thank´s
Hola Ângelo,
if I understand you correctly, you want to customize the field names in the mod_form.php, am I right? Well, these string are being displayed by get_string() function and there is no simple way how to have them varying in different forms. Try to find out some universal translation for them.
If this is not acceptable for you, you will probably want to hack get_string() and lang files to get different strings for different instances. But, more hacks in the Moodle core files represent more work for you during any future upgrade. So try to avoid them if possible.
HTH
if I understand you correctly, you want to customize the field names in the mod_form.php, am I right? Well, these string are being displayed by get_string() function and there is no simple way how to have them varying in different forms. Try to find out some universal translation for them.
If this is not acceptable for you, you will probably want to hack get_string() and lang files to get different strings for different instances. But, more hacks in the Moodle core files represent more work for you during any future upgrade. So try to avoid them if possible.
HTH
Hi David
Yes, i add these lines to mod/certificate/mod_form.php:
$mform->addElement('text', 'customtitle', get_string('customtitle', 'certificate'), array('size'=>'25'));
$mform->setType('customtitle', PARAM_TEXT);
I do create the field customtitle in mdl_certificarte table and now i am able to insert and update this field, this is working.
I am trying to do it the easyest way possible and using less possible hack to use the moodle coding standards.
My doubt now is how to display the customtitle in mod/certificate/type/"allcertificatetypes"/certificate.php
And how to do it without creating the impact that you mention, affecting future upgrades.
Thank´s in advance
Yes, i add these lines to mod/certificate/mod_form.php:
$mform->addElement('text', 'customtitle', get_string('customtitle', 'certificate'), array('size'=>'25'));
$mform->setType('customtitle', PARAM_TEXT);
I do create the field customtitle in mdl_certificarte table and now i am able to insert and update this field, this is working.
I am trying to do it the easyest way possible and using less possible hack to use the moodle coding standards.
My doubt now is how to display the customtitle in mod/certificate/type/"allcertificatetypes"/certificate.php
And how to do it without creating the impact that you mention, affecting future upgrades.
Thank´s in advance
Does the same work in 1.9? And what about Editing the Certificate Title in 1.9?
There are 3 main lang strings that get printed on the certificate. They are found toward the bottom of each type/certificate.php file like this:
cert_printtext(170, 125, 'C', 'Helvetica', 'B', 30, utf8_decode(get_string('titlelandscape', 'certificate')));
cert_printtext(170, 180, 'C', 'Times', 'B', 20, utf8_decode(get_string('introlandscape', 'certificate')));
cert_printtext(170, 280, 'C', 'Helvetica', '', 20, utf8_decode(get_string('statementlandscape', 'certificate')));
Each type has it's own lang string and all of the strings appear in the certificate/lang/ certificate.php file like this:
$string['titlelandscape'] = 'CERTIFICATE of ACHIEVEMENT';
$string['introlandscape'] = 'This is to certify that';
$string['statementlandscape'] = 'has completed the course';
The simplest way to change them is to just change the wording in the lang file, e.g. for the landscape type:
$string['titlelandscape'] = 'Declaration of Achievement';
OR, create your own custom type folder by copying and pasting one of the default folders and giving it a new name, e.g. declaration. Add the name of the new type to your lang file , e.g.:
$string['typedeclaration'] = 'Declaration';
Then add the new strings to the lang file, e.g.:
$string['titledeclaration'] = 'Declaration of Achievement';
Then make that change at the bottom of the type/certificate.php file too, e.g.:
cert_printtext(170, 125, 'C', 'Helvetica', 'B', 30, utf8_decode(get_string('titledeclaration', 'certificate')));
Then, when you want a certificate that prints that particular title, choose the Declaration type when adding the certificate to a course.
cert_printtext(170, 125, 'C', 'Helvetica', 'B', 30, utf8_decode(get_string('titlelandscape', 'certificate')));
cert_printtext(170, 180, 'C', 'Times', 'B', 20, utf8_decode(get_string('introlandscape', 'certificate')));
cert_printtext(170, 280, 'C', 'Helvetica', '', 20, utf8_decode(get_string('statementlandscape', 'certificate')));
Each type has it's own lang string and all of the strings appear in the certificate/lang/ certificate.php file like this:
$string['titlelandscape'] = 'CERTIFICATE of ACHIEVEMENT';
$string['introlandscape'] = 'This is to certify that';
$string['statementlandscape'] = 'has completed the course';
The simplest way to change them is to just change the wording in the lang file, e.g. for the landscape type:
$string['titlelandscape'] = 'Declaration of Achievement';
OR, create your own custom type folder by copying and pasting one of the default folders and giving it a new name, e.g. declaration. Add the name of the new type to your lang file , e.g.:
$string['typedeclaration'] = 'Declaration';
Then add the new strings to the lang file, e.g.:
$string['titledeclaration'] = 'Declaration of Achievement';
Then make that change at the bottom of the type/certificate.php file too, e.g.:
cert_printtext(170, 125, 'C', 'Helvetica', 'B', 30, utf8_decode(get_string('titledeclaration', 'certificate')));
Then, when you want a certificate that prints that particular title, choose the Declaration type when adding the certificate to a course.
Your solution seems much cleaner and easy to control, seems a better aproach than mine and the natural way in the code.
The requirement here was to enable every teacher to call the Certificate and Statement string the way they need, so i customize these files on this way:
At lang/en_utf8
--------------------
Add these two lines:
$string['customtitle'] = 'Customized Title';
$string['customstatement'] = '(completed the course)';
At mod_form.php;
--------------------
$mform->addElement('text', 'customtitle', get_string('customtitle', 'certificate'), array('size'=>'25'));
$mform->setType('customtitle', PARAM_TEXT);
$mform->addElement('text', 'customstatement', get_string('customstatement', 'certificate'), array('size'=>'25'));
$mform->setType('customstatement', PARAM_TEXT);
At "anytype"/certificate.php:
--------------------
//Add these lines
$customtitle = $certificate->customtitle;
$customstatement = $certificate->customstatement;
if( strlen($customtitle)>0 ) {
cert_printtext(48, 170, 'C', 'Helvetica', 'B', 26, utf8_decode($customtitle));
} else {
cert_printtext(48, 170, 'C', 'Helvetica', 'B', 26, utf8_decode(get_string("titleportrait", "certificate")));
}
if( strlen($customstatement)>0 ) {
cert_printtext(48, 330, 'C', 'Helvetica', 'B', 26, utf8_decode($customstatement));
} else {
cert_printtext(48, 330, 'C', 'Helvetica', 'B', 26, utf8_decode(get_string("customstatement", "certificate")));
}
I am still testing this solutions do you see some troubles running these implementations ? if so please let me know .
Best regards Chardelle.
The requirement here was to enable every teacher to call the Certificate and Statement string the way they need, so i customize these files on this way:
At lang/en_utf8
--------------------
Add these two lines:
$string['customtitle'] = 'Customized Title';
$string['customstatement'] = '(completed the course)';
At mod_form.php;
--------------------
$mform->addElement('text', 'customtitle', get_string('customtitle', 'certificate'), array('size'=>'25'));
$mform->setType('customtitle', PARAM_TEXT);
$mform->addElement('text', 'customstatement', get_string('customstatement', 'certificate'), array('size'=>'25'));
$mform->setType('customstatement', PARAM_TEXT);
At "anytype"/certificate.php:
--------------------
//Add these lines
$customtitle = $certificate->customtitle;
$customstatement = $certificate->customstatement;
if( strlen($customtitle)>0 ) {
cert_printtext(48, 170, 'C', 'Helvetica', 'B', 26, utf8_decode($customtitle));
} else {
cert_printtext(48, 170, 'C', 'Helvetica', 'B', 26, utf8_decode(get_string("titleportrait", "certificate")));
}
if( strlen($customstatement)>0 ) {
cert_printtext(48, 330, 'C', 'Helvetica', 'B', 26, utf8_decode($customstatement));
} else {
cert_printtext(48, 330, 'C', 'Helvetica', 'B', 26, utf8_decode(get_string("customstatement", "certificate")));
}
I am still testing this solutions do you see some troubles running these implementations ? if so please let me know .
Best regards Chardelle.
No-that looks good. It would be nice to be able to add custom text when adding a certificate as well as set the placement of it (for example, a text field in mod_form, then two text fields to set the X and Y placement parameters for that text field). I just haven't found the time yet. Currently, there are two custom text fields: custom text and credit hours--but the positioning of those is still hard-coded in the type file.
Where is the "mdl_certificarte table " located ?
The certificate table is in your database.