You need to tell MW to expose the PHP variables in JS, which you do by
adding a ResourceLoaderGetConfigVars hook.

https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars
On Jul 2, 2015 6:21 AM, "Frank Baxmann" <serv...@frankbaxmann.de> wrote:

> Hi Bernhard,
>
> JavaScript (on browser) can not access php variables (on server).
> You have to make them available to JS by sending them to the browser.
> I use additional JS for this, but there is somewhere in MW a class for
> adding variables with MW. And these you can then catch in JS with
> mw.config.get.
>
> Greetings
> Frank
>
> On 02.07.2015 13:07, Krabina Bernhard wrote:
> > Hi,
> >
> > I'm hacking my way around these days and I have a newbie question:
> >
> > If a variable is set in an extension (e.g.
> > $GLOBALS['$egMapsTest'] = 'http://{s}.tile.osm.org/{z}/{x}/{y}.png';
> >
> > How can I access this variable in a JavaScript?
> >
> > The only hint I found so far is
> > var Test2 = mw.config.get('egMapsTest');
> >
> > but this doesn't work...
> >
> > I have the feeling that mw.config.get onyl works for mw variables
> (wg...), but how can I access eg-Variables that are set by an extension?
> >
> > cheers,
> > Bernhard
> >
> >
> ------------------------------------------------------------------------------
> > Don't Limit Your Business. Reach for the Cloud.
> > GigeNET's Cloud Solutions provide you with the tools and support that
> > you need to offload your IT needs and focus on growing your business.
> > Configured For All Businesses. Start Your Cloud Today.
> > https://www.gigenetcloud.com/
> > _______________________________________________
> > Semediawiki-devel mailing list
> > Semediawiki-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/semediawiki-devel
> >
>
>
>
> ------------------------------------------------------------------------------
> Don't Limit Your Business. Reach for the Cloud.
> GigeNET's Cloud Solutions provide you with the tools and support that
> you need to offload your IT needs and focus on growing your business.
> Configured For All Businesses. Start Your Cloud Today.
> https://www.gigenetcloud.com/
> _______________________________________________
> Semediawiki-devel mailing list
> Semediawiki-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/semediawiki-devel
>
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel

Reply via email to