i've developed a plugin his role is to add simple menu button called Custom Button when i click that button it will display a message sended from another php file passed in argument of main function which display the message .My problem is when i send a string value from file.php file to the function view_button_content passing the value by argument "view_button_content($str1)"in Moodle App it displayed me everytime Array despite it is string not array type it is declared as string .here is a pictures describing clearly the problem and here is the code of 3 files.
- Here is the code of db/mobile.php :
<?php
$addons = [
'local_test' => [
'handlers' => [
'hello' => [
'delegate' => 'CoreMainMenuDelegate',
'method' => 'view_button_content',
'displaydata' => [
'title' => 'CustomButton',
'icon' => 'earth',],],],
'lang' => [
['CustomButton', 'local_test'],],],];
here is the code of classes/output :
<?php
namespace local_test\output;
class mobile {
public static function view_button_content($ value) {
return [
'templates' => [
[
'id' => 'main',
'html' => '<h1 class="text-center">{{ "' . $value . '" |translate }}</h1>',],],];}}
- here is the code of file.php
<?php
// Include mobile.php from the classes/output folder
require_once(__DIR__ . '/classes/output/mobile.php');
$str1="Hello worldddd";
// Call the view_button_content method of the mobile class
$mob_inst = new \local_test\output\mobile();
$mobile_templates=$mob_inst->view_button_content($str1);