This question about Documentation: Answered
How do I override a WebPreferences variable with a personal variable?
I'm working on a skin. The templates all seem to be behaving very nicely. Some of the behaviour of the skin is based on variables being on or off. These are new variables (not already defined anywhere in foswiki).
So I set the default values for those variables in the
WebPreferences topic of the web in which I'm using the new skin. So far, so good. Things work as they should.
But I would like to let users override those variables. I understand this can be done in one's "personal topic" in
Main
web.
So in my personal topic, I set the variables as I personally want them.
However, when I go into that web, my overrides don't seem to take. The variables are still set to the values in that web's
WebPreferences.
Am I missing something?
--
FilSalustri - 04 Dec 2009
Sounds like it should be working. What are you using to read/check the variables? Can you paste it here? Also, what happens if you try to override one of Foswiki's "normal" variables? (maybe something like WEBCOPYRIGHT for testing, as long as it isn't finalised). Does that work as expected?
As long as the variables are not finalised, they should work as you describe.
--
AndrewJones - 04 Dec 2009
Ask and ye shall receive. The skin I'm working on is called Maj. Feel free to check the pages themselves - only please use Firefox as I'm having "issues" with IE.
In
http://deseng.ryerson.ca/t/bin/view/Design/WebPreferences, I have:
* Tweak the topic action buttons at the top of the page.
* Set MAJATTACHACTION = off
* Set MAJRAWVIEWACTION = off
* Set MAJRAWEDITACTION = off
In
http://deseng.ryerson.ca/t/bin/view/Main/FilSalustri (my personal topic), I have:
* For System.MajSkin:
* Set MAJATTACHACTION = on
* Set MAJRAWVIEWACTION = on
* Set MAJRAWEDITACTION = on
In
viewtopicactionbuttons.maj.tmpl
, which is included in
view.maj.tmpl
, I have this rather ugly template (I have inserted extra space & newlines to make it readable):
%TMPL:DEF{"abbreviatedtopicactionbuttons"}%
%IF{"$MAJEDITACTION='off'" then="<nop>" else="$percntTMPL:P{$quotaction_activatable_edit_or_create$quot}$percnt"}%
%IF{"$MAJATTACHACTION='off'" then="<nop>" else="$percntTMPL:P{$quotaction_activatable_attach$quot}$percnt"}%
%IF{"$MAJPRINTABLEACTION='off'"
then="<nop>"
else="<span><a href='$percntSCRIPTURLPATH{$quotview$quot}$percnt/$percntWEB$percnt/$percntTOPIC$percnt?cover=print%QUERYPARAMSTRING%%REVARG%' rel='nofollow' $percntMAKETEXT{$quottitle='Printable version of this topic' accesskey='p'>&Print version$quot}$percnt</a></span>$percntTMPL:P{$quotsep$quot}$percnt"}%
%IF{"$MAJBACKLINKSACTION='off'"
then="<nop>"
else="$percntTMPL:P{$quotaction_backlinks_simple$quot}$percnt"}%
%IF{"$MAJRAWVIEWACTION='off'"
then="<nop>"
else="$percntTMPL:P{$quotaction_raw_or_view$quot}$percnt"}%
%IF{"$MAJRAWEDITACTION='off'"
then="<nop>"
else="$percntTMPL:P{$quotaction_activatable_raw_edit$quot}$percnt"}%
%IF{"$MAJMOREACTION='off'" then="<nop>" else="$percntTMPL:P{$quotactivatable_more$quot}$percnt"}%
%TMPL:END%
And I display the value
MAJATTACHACTION
in
http://deseng.ryerson.ca/t/bin/view/Design/WebHome as a test.
So, by my reckoning, the values in my personal topic should override those in the
WebPreferences topic.
However, when I'm logged in as
FilSalustri, it appears that MAJATTACHACTION is off, and it behaves that way too.
I'm sure it's something stupid I've done, but I can't for the life of me find it.
--
FilSalustri - 05 Dec 2009
I just updated a unit test to check the specific case as per the doc; and it fails, so you are not stupid, just the first person to try and do this. The problem appears to be that a user setting will not override a web setting. However it works if you finalise the user setting.
Please follow up with a task; it's a toss-up whether we fix the code, or the doc.
--
CrawfordCurrie - 11 Dec 2009
I'm grading 220 design journals and 40 design reports at the moment; my spare time is pretty much nil. But I'll follow up as you've asked, as soon as I can (before Xmas for sure). Thanks for fast treatment.
--
FilSalustri - 11 Dec 2009
Hi Fil, Hi Crawford.
The precendence level of preferences is, highest to lowest: (as per
doc)
- Session
- Topic
- Web
- Parent web
- User topic
- Local site settings (SitePreferences)
- Plugins topics
- Default preferences (DefaultPreferences)
It means that web settings override user settings. Users can
force their settings to override higher levels using FINALPREFERENCES. (Like
I use for WYSIWYG setting).
--
GilmarSantosJr - 11 Dec 2009
Sorry Gilmar, you are quite right. My mistake. I should have got that right, since I wrote the doc :-/. This is from the (tm)wiki doc:
You can set variables in all the following places:
- local site level in System.TWikiPreferences
- plugin topics (see TWikiPlugins)
- local site level in Main.SitePreferences
- user level in individual user topics in Main web
- web level in WebPreferences of each web
- topic level in topics in webs
- session variables (if sessions are enabled)
Settings at higher-numbered levels override settings of the same variable at lower numbered levels, unless the variable was included in the setting of FINALPREFERENCES at a lower-numbered level, in which case it is locked at the value it has at that level.
-- CrawfordCurrie - 11 Dec 2009
I, too, am grateful for the correction. Next time, I'll make more of an effort to read the doc, so I can make less of an effort wiping the egg off my face. Thanks again.
--
FilSalustri - 15 Dec 2009