Use variable of module in frontpage

Hey. I want to use a variable of my own module in the frontage main. How I get access to that variable?

I tried this

Template::Set('MODULE\_TEST', $clients);

but does not work… Thats the answer from .

Many thanks!

usualy it returns as an array have you tried to print_r($MODULE_TEST);  and see what it returns ?

26 minutes ago, Vangelis said:

usualy it returns as an array have you tried to print_r($MODULE_TEST);  and see what it returns ?

there’s nothing..hm…

What other code doyou have ?

I cannot say that I have understood what do you mean exactly.. Could you please explain it a little bit better?

4 minutes ago, servetas said:

I cannot say that I have understood what do you mean exactly.. Could you please explain it a little bit better?

I created the InstantWeather Module. Okay. Now I have there an variable for example “$iwm_metar”.

Now, how can I show THIS $iwm_metar variable on the frontpage_main for example? Now it works only for the Module-page of InstantWeather.

Hope you understand now^^

 

THANKS

I do not know if something like this can be done (directly getting a variable from a function without running it). What you can do is creating a new function in your module and call it in your frontpage using the following part of code:

<?php MainController::Run('YOUR_MODULE_NAME', 'YOUR_FUNCTION_NAME', 'SET HERE ANY FUNCTION PARAMETERS IF ANY); 
?>

And anything you echo inside the function will be shown where you placed the above part of code.

13 minutes ago, servetas said:

I do not know if something like this can be done (directly getting a variable from a function without running it). What you can do is creating a new function in your module and call it in your frontpage using the following part of code:

<?php MainController::Run('YOUR_MODULE_NAME', 'YOUR_FUNCTION_NAME', 'SET HERE ANY FUNCTION PARAMETERS IF ANY); ?>

And anything you echo inside the function will be shown where you placed the above part of code.

Mh… I tried something like this, is it correct?

I first added a function

public function get\_metar() { echo "HELLO"; }

and then I added the code in my frontpage_main

\<?php MainController::Run('InstantWeather', 'get\_metar()'); ?\>

 

Nothing happens. Even if I declare a new variable in the get_metar() function and ask for it in the frontpage. Any ideas?

Use this:

\<?php MainController::Run('InstantWeather', 'get\_metar', ''); ?\>

 

1 Like

Just now, servetas said:

Use this:

<?php MainController::Run(‘InstantWeather’, ‘get_metar’, ‘’); ?>

 

WORKS for me! Thank you very very much!!