Tags:
create new tag
, view all tags
A small enhancement for %URLPARAM{}%:

It supports now a newline="..." argument, e.g. %URLPARAM{ "description" newline="<br />" }%

This is useful if you have a textarea field content passed to a topic, and you want to process the content on a single physical line, for example to pass it on to another variable (like applying it to a SpreadSheetPlugin formula), or to put it into a TWiki table.

Enhancement is in TWikiAlphaRelease (for CairoRelease) and TWiki.org. Docs in TWikiVariables are updated.

Feedback and ideas for enhancements is appreciated. See also related UrlParamWithDefaultValue.

-- PeterThoeny - 23 Aug 2003

So, my impression is that newlines in the topic are replaced with whatever is specified after "newline="? I guess that must be the case — I think a more explicit statement would be helpful to people like me, so I don't have to think too much. wink

-- RandyKramer - 23 Aug 2003

Another useful application for this is to process formdata in a Plugin instead of a standalone script that clutters the bin directory. For example, Plugins like CommentPlugin and ActionTrackerPlugin could be done without standalone scripts:

  • The form gets submitted to a Plugin maintenance topic, e.g. a CommentPluginAdmin topic; possibly calling viewauth instead of view for authenticated action
  • The form has, among other fields, a hidden pluginaction field of value save
  • The admin topic passes the parameters along to the Plugin, e.g.:
    • %COMMENT{ pluginaction="%URLPARAM{pluginaction}%" otherparam="%URLPARAM{otherparam}%" }%
    • A newline-escaped parameter can be added if needed:
    • textareaparam="%URLPARAM{"textareaparam" newline="%_NL_%" }%"
  • The pluginaction parameter makes sure that a normal topic view does not fire off the save action.
  • If and only if the pluginaction is save, the save action is performed. The Plugin could return a thank you message.

Here is a silly example for testing: Enter a few short lines

Text area: Resulting URL param "as is": URL param with BRs for new lines:

 

 


Simulated Plugin command: %COMMENT{ pluginaction="" testarea="" }%

-- PeterThoeny - 23 Aug 2003

In my environment I get a URL parameter ?testarea=xxx%0D%0Ayyy when entering two lines (xxx and yyy). I am intersted to know if other environments produce different line endings. This enhancement should handle different line endings correctly.

Who Environment Line ending
PeterThoeny Win XP, IE 6.0 and Netscape 4.7x %0D%0A (CR LF)
RandyKramer Knoppix 3.2, konqueror 3.1.1 %0D%0A (CR LF)
     
     

-- PeterThoeny - 23 Aug 2003

Topic revision: r8 - 16 Aug 2004 - 05:54:15 - PeterThoeny
 
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback