Extension talk:MyVariables

Hello there,

this is a very useful extension but it do not work the way i expected. This variables seem to be not actual when a page is reloaded. I changed the return value of the variable but it has the old value (after reloading the page). When i worte "Hello " on my main page an i logged out, it always shows my former login name. I thougt that this could be a caching problem, but when a fried edited the main page and I visited it afterwards, the page shows the login name of my friedn.... There is something strange about parsing the CURRENTXYZ values. Is there a solution?

Thanks in advance 88.76.203.237--
 * Yeah I've noticed that as well, I think it's that the current user variable reset after logging out after the page renders, but I'll check it out properly when I get some time. --Nad 22:09, 10 March 2007 (UTC)

Hi Nad,

i tried different ways but it is really strange and does not work. My php skills are not that good (as same as my english skills :-) ), but i ask myself how the whole session is handled. When i am logged in everything (for example MY watchlist) is rendered depending on my login name. So i think there must be a reliable information about the user which is currently logged in. (Or how does all this customized rendering work?). Naive as i am, i expected $wgUser stores this information, but obviously it does not. Greetings from Germany. ---
 * I've recently found that this extension doesn't work in 1.9.x - it works in 1.4 - 1.6.x. I'm working a lot on some 1.9's now and will need to get it going for that so I'll update it here when I get it working. --Nad 21:49, 14 March 2007 (UTC)


 * Hi Nad,
 * i hope i do not bother you. I forgot to mention, that "our wiki" is running a 1.6.9 version. I am now really suprised that you do not notice this problems in a 1.6.x version. I am running two 1.6.9 wiki on different target systems (Windows XP / PHP 5 AND Linux PHP 4) and in both i noticed this problem. I am trying to get throug the source codes but as i mentioned my skill are not that good.
 * I believe that the parsing of the wiki code does not work correctly. For testing purposes i customized your code to render
 * $user=new User;
 * $user->getName;
 * but this does also have the same "side effects". Sometimes i think this code is not really rendered each time. Then i edit the site and click on "preview" i ALWAYS get the correct value of the variable.
 * But this seems to be not only "your problem" the standard values like NUMBEROFARTICLES act the same (strange) way.
 * I hope my information are helping you anyway. Have a nice day. --193.19.114.132
 * All I can think of is that maybe the pages you're viewing are cached, it's always good to turn off the caching when experimenting with the following couple if lines in LocalSettings.php,
 * $wgEnableParserCache = false;
 * $wgOut->enableClientCache(false);
 * The $wgUser global is definately the object you want which holds the info on the currently logged in user. --Nad 20:19, 15 March 2007 (UTC)
 * Hello Nad, thank you very much for your competent help. I disabled the Cache in LocalSettings.php (only the $wgEnableParserCache=false) and everything works as i expected. Thanks a lot for your support!! Have a nice weekend! Greetings from Germany. --193.19.114.132
 * Excellent, glad to hear it's working out ;-) --Nad 21:18, 16 March 2007 (UTC)

Parser Caching?
Hello,

in 1.8.4, variables retain their values after having been computed once. Touching LocalSettings.php helps, so I'm pretty shure there must be some caching problem.


 * Workaround:set $wgEnableParserCache to false in LocalSettings.php


 * Solution:Sorry, Nad, I'm new to MediaWiki and as well to php. There must be some solution to prevent pages that contain dynamic variables from being cached. Perhaps setting some per-page flag... I don't know.

Harm in disabling?
I want to put a cool icon and edit instruction on the unedited personal page (#if on Media Wiki:Noarticletext), but then the CURRENTUSER variable has to be functional.

What will be damaged if I set $wgEnableParserCache to false? I guess at least it would make the count of the number of times each page has been displayed to go crazy... any other damages? Maybe performance? Thank you :-) --87.68.208.47 22:35, 18 May 2007 (UTC)
 * Completely disabling the parser cache will affect performance badly, especially if you have any high traffic to serve. I've added a line in to the CURRENTUSER example which marks the returned content as uncacheable, so see if that does the trick --Nad 23:38, 18 May 2007 (UTC)

More Examples?
I'm trying to create new variables with this extension that call user stats like registration date and last login of a user. It's for a template so the user is called with. Any hints? Thanks. --Subfader 21:57, 14 May 2008 (UTC)
 * It would probably be easier to make it as a parser function such as #user and make the parameter the property you want to read, that way you can easily extend the number of properties etc without having to create many different magic words. --Nad 23:28, 14 May 2008 (UTC)

Not working for me (MW1.12.0)
Hi - I've tried this using the include in LocalSettings.php, but I just get a few lines of programming superimposed at the top of the wiki page, and the variable doesn't work. Should it work in 1.12.0? Thanks. - Derrickfarnell 11:06, 19 May 2008 (UTC)
 * MW 1.12.0 may not work due to the significant changes to the way the parser works. --Zven 20:37, 19 May 2008 (UTC)
 * WOrked fine for me on 1.12.0rc. Try placing the line above all other extension includes / requires --Subfader 06:41, 20 May 2008 (UTC)
 * Perhaps I'm doing something wrong: I created a folder, within the extension folder, called 'MyVariables', and then created a php file within that folder with the name MyVariables.php, and containing simply the code provided here. I then added the following line at the end of LocalSettings.php, although before all the other lines I've added at the end in the past:


 * require_once( "$IP/extensions/MyVariables/MyVariables.php" );


 * Should that work?! It still doesn't for me... I just get a few lines of code superimposed at the top of every page, which is what has happened in the past when other extensions have not worked or been incorrectly installed.


 * Is there perhaps another way of automatically inserting the user's username into a page? I'm wanting the user's username to be automatically inserted in the form field on this page:


 * http://www.chainsofreason.org/wiki/Create_a_new_chain


 * - I can get the date and time automatically inserted, but the user has to manually replace 'User' with their username. Derrickfarnell 09:59, 22 May 2008 (UTC)


 * Now working after adding  The functions disk_total_space and diskfreespace use $wgSharedUploadDirectory to get the path information. The variables can be processed using ParserFunctions to get the required output for users on a wiki page. --ThT 14:47, 2 June 2008 (UTC)

Give out javascript
Is it possible to give out a simple javascript this way? Something like $ret = echo ('Text ? --Subfader 19:17, 5 June 2008 (UTC)
 * Give it a try, if not you can set up a parser-function instead which can be made to return HTML --Nad 21:16, 7 June 2008 (UTC)

Database query?
Is it possible to give out a database query? I'd like to use a code to display 3 random mp3 links from Special:MIMESearch/audio/mp3 on an article page. --Subfader 23:14, 25 September 2008 (UTC)