SID-00018: Variable Handling
| Status: |
Answered |
TWiki version: |
4.2.3 |
Perl version: |
5.10.0 |
| Category: |
CategoryPlugins |
Server OS: |
Windows |
Last update: |
16 years ago |
Hallo,
how can i access to a VAR in the view script when it was set in a topic?
I have set it in the topic text like this:
I have tried it with TWiki::Prefs::getPreferencesValue( "VARNAME" ) and TWiki::Func::getPreferencesValue( "VARNAME" ) but i m getting an error: "Undefined Subroutine ...".
Can someone explain me please what i have to do, to access to a self created VAR?
Thx alot.
Thomas
--
ThomasMueller2009 - 08 Jan 2009
Discussion and Answer
Not sure why you get the "Undefined Subroutine ..." error. Have you initialized your plugin properly?
Use only official
TWiki::Func functions, not internal ones like
TWiki::Prefs.
TWiki::Func::getPreferencesValue can retrieve the value of preferences setting. Remember that pref settings can be overloaded (2 x site level -> web level -> page level), e.g. you get the end result of the pref setting. Watch out for the $NO_PREFS_IN_TOPIC plugin variable. See docs in
TWikiFuncDotPm
--
PeterThoeny - 09 Jan 2009
Hallo,
sorry for delay ...
I added now "require Twiki::Func" and the error "Undefined Subroutine..." is gone.
But I m getting now the error "Can't call method getPreferencesValue on undefined value".
Do I have to register my created VARNAME somewhere?
I have set the VARNAME in a Topic and want to access the value in a modified view-Script. Something like the Accesspermission Routine.
--
ThomasMueller2009 - 16 Jan 2009
Is this a standalone script? Make sure to initialize it properly before you call any
TWiki::Func function. Look at the
twiki/tools/mailnotify or
twiki/bin/statitics scripts for inspiration.
--
PeterThoeny - 16 Jan 2009
Sorry but both script doesn't helped me to get an idea.
Yes, it is a standalone script.
It is a modified version of the
PeterKlausner's
CacheAddon. It is working fine but i want to define in the topic text if a topic has to be cached or not.
The cache script is a new view script what will call a render script (the original view script) after some checks.
But i cannot access to the value of my VAR in the topic.
I tried to write a Plugin for handling it. I registered there a
TagHandler which is working. If I set a new value in the topic the handler shows correctly the new value.
But I still have no access to it in the new view script. I tried it with "params->..." and with getPreferencesValue but getting everytime "Can't call ... undifined value".
I don't know what to do.
--
ThomasMueller2009 - 20 Jan 2009
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.