# Use variable of module in frontpage

**URL:** <https://forum.phpvms.net/t/use-variable-of-module-in-frontpage/11560>\
**Category:** Development Help\
**Created:** [January 10, 2017, 11:22am UTC](https://forum.phpvms.net/t/use-variable-of-module-in-frontpage/11560 "2017-01-10T11:22:07Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karamellwuerfel](https://forum.phpvms.net/user_avatar/forum.phpvms.net/karamellwuerfel/32/910_2.png) [@Karamellwuerfel](https://forum.phpvms.net/u/Karamellwuerfel)\
**Post date:** [January 10, 2017, 11:22am UTC](https://forum.phpvms.net/t/use-variable-of-module-in-frontpage/11560/1 "2017-01-10T11:22:07Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Vangelis](https://forum.phpvms.net/user_avatar/forum.phpvms.net/vangelis/32/38_2.png) [@Vangelis](https://forum.phpvms.net/u/Vangelis)\
**Post date:** [January 10, 2017, 6:18pm UTC](https://forum.phpvms.net/t/use-variable-of-module-in-frontpage/11560/2 "2017-01-10T18:18:29Z")

</div>

usualy it returns as an array have you tried to print\_r($MODULE\_TEST); &nbsp;and see what it returns ?

---

<div class="post-metadata">

**Author:** ![Karamellwuerfel](https://forum.phpvms.net/user_avatar/forum.phpvms.net/karamellwuerfel/32/910_2.png) [@Karamellwuerfel](https://forum.phpvms.net/u/Karamellwuerfel)\
**Post date:** [January 10, 2017, 6:46pm UTC](https://forum.phpvms.net/t/use-variable-of-module-in-frontpage/11560/3 "2017-01-10T18:46:08Z")

</div>

> 26 minutes ago, Vangelis said:
> 
> usualy it returns as an array have you tried to print\_r($MODULE\_TEST); &nbsp;and see what it returns ?

there’s nothing..hm…

---

<div class="post-metadata">

**Author:** ![Vangelis](https://forum.phpvms.net/user_avatar/forum.phpvms.net/vangelis/32/38_2.png) [@Vangelis](https://forum.phpvms.net/u/Vangelis)\
**Post date:** [January 11, 2017, 5:53am UTC](https://forum.phpvms.net/t/use-variable-of-module-in-frontpage/11560/4 "2017-01-11T05:53:36Z")

</div>

What other code doyou have ?

---

<div class="post-metadata">

**Author:** ![servetas](https://forum.phpvms.net/user_avatar/forum.phpvms.net/servetas/32/75_2.png) [@servetas](https://forum.phpvms.net/u/servetas)\
**Post date:** [January 12, 2017, 10:07am UTC](https://forum.phpvms.net/t/use-variable-of-module-in-frontpage/11560/5 "2017-01-12T10:07:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Karamellwuerfel](https://forum.phpvms.net/user_avatar/forum.phpvms.net/karamellwuerfel/32/910_2.png) [@Karamellwuerfel](https://forum.phpvms.net/u/Karamellwuerfel)\
**Post date:** [January 12, 2017, 10:13am UTC](https://forum.phpvms.net/t/use-variable-of-module-in-frontpage/11560/6 "2017-01-12T10:13:56Z")

</div>

> 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&nbsp;$iwm\_metar variable on the frontpage\_main for example? Now it works only for the Module-page of InstantWeather.

Hope you understand now^^

&nbsp;

THANKS

---

<div class="post-metadata">

**Author:** ![servetas](https://forum.phpvms.net/user_avatar/forum.phpvms.net/servetas/32/75_2.png) [@servetas](https://forum.phpvms.net/u/servetas)\
**Post date:** [January 12, 2017, 10:17am UTC](https://forum.phpvms.net/t/use-variable-of-module-in-frontpage/11560/7 "2017-01-12T10:17:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Karamellwuerfel](https://forum.phpvms.net/user_avatar/forum.phpvms.net/karamellwuerfel/32/910_2.png) [@Karamellwuerfel](https://forum.phpvms.net/u/Karamellwuerfel)\
**Post date:** [January 12, 2017, 10:34am UTC](https://forum.phpvms.net/t/use-variable-of-module-in-frontpage/11560/8 "2017-01-12T10:34:20Z")

</div>

> 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()'); ?\>

```

&nbsp;

Nothing happens. Even if I declare a new variable in the&nbsp;get\_metar() function and ask for it in the frontpage. Any ideas?

---

<div class="post-metadata">

**Author:** ![servetas](https://forum.phpvms.net/user_avatar/forum.phpvms.net/servetas/32/75_2.png) [@servetas](https://forum.phpvms.net/u/servetas)\
**Post date:** [January 12, 2017, 10:36am UTC](https://forum.phpvms.net/t/use-variable-of-module-in-frontpage/11560/9 "2017-01-12T10:36:58Z")

</div>

Use this:

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

```

&nbsp;

---

<div class="post-metadata">

**Author:** ![Karamellwuerfel](https://forum.phpvms.net/user_avatar/forum.phpvms.net/karamellwuerfel/32/910_2.png) [@Karamellwuerfel](https://forum.phpvms.net/u/Karamellwuerfel)\
**Post date:** [January 12, 2017, 10:38am UTC](https://forum.phpvms.net/t/use-variable-of-module-in-frontpage/11560/10 "2017-01-12T10:38:18Z")

</div>

> Just now, servetas said:
> 
> Use this:
> 
> \<?php MainController::Run(‘InstantWeather’, ‘get\_metar’, ‘’); ?\>
> 
> &nbsp;

WORKS for me! Thank you very very much!! &nbsp;
