How to use a menuphase in a context

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

How to use a menuphase in a context

Post by btrade »

Hi,

I need to use a menuphase in a context?
$this->setSuccessMessage("Go into - ".$Language->MenuPhrase("2811", "MenuText")); not work


kirondedshem
User
Posts: 642

Post by kirondedshem »

It should work, ive just tested this exact code of yours, execpt I first opened the language file and scrolled to the <project> tag and read out one of the menu ids, for example mine was 16 like.
<project>
<phrase id="bodytitle" value="some title" />
<phrase id="footertext" value="some footer text" />
<menu id="16">
<phrase id="menutext" value="vw event" />
</menu>

SO:

  1. check your language file to see if there really exists a menu with your id.
  2. when calling it from a phpmaker event do like so
    // Page Load event
    function Page_Load() {

    $this->setSuccessMessage("Go into - ".Language()->MenuPhrase("16", "MenuText"));

}

If calling from a custom file then do like
var_dump($Language->MenuPhrase("13", "MenuText"));


btrade
User
Posts: 357

Post by btrade »

I use really exists a menu with id 2811.

I call this msg in Row_CustomAction.
But I see error
( ! ) Notice: Undefined variable: Language in J:\home\translator\www\backoffice\app_orderslist.php on line 3378
( ! ) Fatal error: Call to a member function Phrase() on null in J:\home\translator\www\backoffice\app_orderslist.php on line 3378


btrade
User
Posts: 357

Post by btrade »

With global $Language; the result is empty

function Row_CustomAction($action, $row) {
// Return FALSE to abort

	global $Language;

btrade
User
Posts: 357

Post by btrade »

english.xml
...
<menu id="2811">
<phrase id="menutext" value="Subscribe" />
</menu>
...


kirondedshem
User
Posts: 642

Post by kirondedshem »

Language in J:\home\translator\www\backoffice\app_orderslist.php on line 3378
Fatal error: Call to a member function Phrase() on null in J:\home\translator\www\backoffice\app_orderslist.php on line 3378
This is happenig because you are not accessing th global langauge object the right way, look closely at my php code:
NOTE:If you look into help file "Some Global Functions", you will see how they refer toa language object, BUt basically

Language() is alraedy a global variable so you dont have to put global $Language; anywhere so do the following, SO REFER TO LANGUAGE OBJECT EXACTLY LIKE BELOW
function Row_CustomAction($action, $row) {
$this->setSuccessMessage("Go into - ".Language()->MenuPhrase("16", "MenuText"));
return TRUE;
}

OR ALTERNATIVELY IF YOUWANT TO ACCESS IT FROM GLOBAL OBJECT
function Row_CustomAction($action, $row) {
$this->setSuccessMessage("Go into - ".$GLOBALS["Language"]->MenuPhrase("16", "MenuText"));
return TRUE;
}


Post Reply