Use Language_Load server event to set footer text

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
mfabbri71
User
Posts: 19

Use Language_Load server event to set footer text

Post by mfabbri71 »

I'm using phpmaker v2023.10. In editor I found Language_Load() public function. When generated in src/Language.php I found languageLoad() public function
The issue is that? Because this code is never applied...

  $footertext = getCopyYear();
  $this->setPhrase("footertext", $footertext);
 ....
 ....

The same code Work perfect in v2022
Where is the issue ?
Thanks


mobhar
User
Posts: 11700

Post by mobhar »

That is not the issue. PHPMaker will generate the function in the generated code becomes languageLoad(), even in the Editor Code of PHPMaker project its name is Language_Load().

As long as you have seen your code in the generated src/Language.php file, then it should work.

Make sure you have already put that getCopyYear() global function under Server Events -> Global -> All Pages -> Global Code.


mfabbri71
User
Posts: 19

Post by mfabbri71 »

The issue is in language.php I can't see the output generated by the function:

function GetCurrentCopyYear() {
   $output ="©";
   $copyYear= 2022;
   $curYear = date("Y");
   $output .= $copyYear.(($copyYear !=$curYear) ? "-".$curYear : "");
   $output .= " Università degli Studi della Tuscia - USIC - Ufficio Servizi Informatici di Comunicazione";
   return $output;
}

this is never applied:

// Language Load event
    public function languageLoad()
    {
        // Example:
        //$this->setPhrase("MyID", "MyValue"); // Refer to language file for the actual phrase id
        //$this->setPhraseClass("MyID", "fas fa-xxx ew-icon");
        // Refer to https://fontawesome.com/icons?d=gallery&m=free [^] for icon name
        $footertext = GetCurrentCopyYear();
        //$this->setPhrase("List","List");
        //$this->setPhrase("1","List");
            $this->setPhrase("footertext",$footertext);
        if (CurrentLanguageID() == "en" || CurrentLanguageID() == "us") {
        	$this->setPhrase("footertext",$footertext);
......
.....

mobhar
User
Posts: 11700

Post by mobhar »

mobhar wrote:

Make sure you have already put that getCopyYear() global function under Server Events -> Global -> All Pages -> Global Code.

It will be generated into src/userfn.php file, not src/Language.php file.


mfabbri71
User
Posts: 19

Post by mfabbri71 »

GetCurrentCopyYear() is in userfn.php


mfabbri71
User
Posts: 19

Post by mfabbri71 »

the code above is never applied. Instead is loaded the default string defined in lang/italian.xml
even if It is null.

// Language Load event
    public function languageLoad() {
        $footertext = GetCurrentCopyYear();
       $this->setPhrase("footertext",$footertext);
...
...

arbei
User
Posts: 9348

Post by arbei »

mfabbri71 wrote:

if (CurrentLanguageID() == "en" || CurrentLanguageID() == "us") {
$this->setPhrase("footertext",$footertext);

If you are still checking "en" or "us", be reminded that the language IDs are changed, it should be, e.g. "en-US".


mobhar
User
Posts: 11700

Post by mobhar »

So, simply change this code:

if (CurrentLanguageID() == "en" || CurrentLanguageID() == "us") {

to:

if (CurrentLanguageID() == "en-US") {

mfabbri71
User
Posts: 19

Post by mfabbri71 »

The issue is not the if statement. This is the code:

public function languageLoad()
{
        $footertext = GetCurrentCopyYear();
        $this->setPhrase("footertext",$footertext);
}

the custom phrase is never loaded.


mobhar
User
Posts: 11700

Post by mobhar »

You may post your latest/updated code for more discussion.


arbei
User
Posts: 9348

Post by arbei »

Be reminded that "footertext" is not a global phrase, it is a project phrase, so you need to use setProjectPhrase().


mfabbri71
User
Posts: 19

Post by mfabbri71 »

Thanks mobhar but this is the latest update and I have the same issue.
It is loaded the phrase generated in lang/english.xml and lang/italian.xml
and not the custom phrases
Thanks


mfabbri71
User
Posts: 19

Post by mfabbri71 »

@arbel
you are right
wich are project phrases to look up ?
or where i can found these in documentation ?
Thanks


arbei
User
Posts: 9348

Post by arbei »

Global phrases are those you find in the language files. Table/Field/Chart/Project phrases are those you set in the Multi-Language Property Editor.


Post Reply