1

Topic: Make variables available through Wolfcms

Hi,

I do not understand how Wolfcms works :s

How can I use variables (global) set on files (include_once "",…), snippets, plugins, and make them available through the whole website?

Seems Wolfcms deal strangely with global variables, as they are never "reachable" outside their first place?

Thanks.

Thumbs up

2

Re: Make variables available through Wolfcms

Use the config file to set/load your variables globally.

3

Re: Make variables available through Wolfcms

Is there anyway to restore the default behavior? As there is a lot of variables, and they are supposed to be modified regularly.

Thumbs up

4

Re: Make variables available through Wolfcms

I do not understand your question, perhaps you can give an example?

5

Re: Make variables available through Wolfcms

I would like to put some data, say prices, and make them available in all Wolfcms.

If I write in php files something like this:

<?php
//  test1.php file

include_once "test2.php";
echo $var;
?>


<?php
//  test2.php file
$var = 0;
?>


I am able to print '0' .

But with Wolfcms, it does not work, even if I include snippets, files, plugins.

Thumbs up

6

Re: Make variables available through Wolfcms

Why not build a plugin to deal with prices?
You would have access to them sitewide.

7

Re: Make variables available through Wolfcms

kirk7007 wrote:

I would like to put some data, say prices, and make them available in all Wolfcms.

If I write in php files something like this:

<?php
//  test1.php file

include_once "test2.php";
echo $var;
?>


<?php
//  test2.php file
$var = 0;
?>


I am able to print '0' .

But with Wolfcms, it does not work, even if I include snippets, files, plugins.

Its probally due to PHP's scope: http://php.net/manual/en/language.variables.scope.php

8

Re: Make variables available through Wolfcms

Well, that's what I thought in the first place, but:

  • Even if I declare a variable as global, it does not work.

  • These, needed, variables are set outside of any function, so they should be available.

  • These, needed, variables are called outside of any function, so they should be printable (like the example written previously).

  • Variables are, by default, global. So I should be able, in anyway, to reach them, outside of any function, but it is not the case.

  • In my own code, I get the expected behavior, but not in Wolfcms.

Thumbs up

9

Re: Make variables available through Wolfcms

You should use a function that returns the required variables, array or object
from within a plugin that will work.

10

Re: Make variables available through Wolfcms

Ok, thanks.

Thumbs up