customize some titles in moodle 1.8

customize some titles in moodle 1.8

by Ângelo Rigo -
Number of replies: 10
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

Average of ratings: -
In reply to Ângelo Rigo

Re: customize some titles in moodle 1.8

by Chardelle Busch -
Picture of Core developers
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.
Average of ratings: Useful (1)
In reply to Chardelle Busch

Re: customize some titles in moodle 1.8

by Ângelo Rigo -
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
In reply to Ângelo Rigo

Re: customize some titles in moodle 1.8

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
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
In reply to David Mudrák

Re: customize some titles in moodle 1.8

by Ângelo Rigo -
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
In reply to Ângelo Rigo

Re: customize some titles in moodle 1.8

by Clinton Randolph -
Does the same work in 1.9?  And what about Editing the Certificate Title in 1.9?
In reply to Clinton Randolph

Re: customize some titles in moodle 1.8

by Chardelle Busch -
Picture of Core developers
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.


In reply to Chardelle Busch

Re: customize some titles in moodle 1.8

by Ângelo Rigo -
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.
In reply to Ângelo Rigo

Re: customize some titles in moodle 1.8

by Chardelle Busch -
Picture of Core developers
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 yettongueout. 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.
In reply to Ângelo Rigo

Re: customize some titles in moodle 1.8

by J B -
Where is the "mdl_certificarte table " located ?