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, I have:

   * Tweak the topic action buttons at the top of the page.
      * Set MAJATTACHACTION = off
      * Set MAJRAWVIEWACTION = off
      * Set MAJRAWEDITACTION = off

In (my personal topic), I have:

   * For System.MajSkin:
      * Set MAJATTACHACTION = 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):


%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"}%

   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{"$MAJMOREACTION='off'" then="<nop>" else="$percntTMPL:P{$quotactivatable_more$quot}$percnt"}%


And I display the value MAJATTACHACTION in 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)
  1. Session
  2. Topic
  3. Web
  4. Parent web
  5. User topic
  6. Local site settings (SitePreferences)
  7. Plugins topics
  8. 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:

  1. local site level in System.TWikiPreferences
  2. plugin topics (see TWikiPlugins)
  3. local site level in Main.SitePreferences
  4. user level in individual user topics in Main web
  5. web level in WebPreferences of each web
  6. topic level in topics in webs
  7. 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

QuestionForm edit

Subject Documentation
Version Foswiki 1.0.7
Status Answered
Topic revision: r8 - 15 Dec 2009, FilSalustri - This page was cached on 06 Aug 2020 - 09:44.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy