Skip to content

Commit

Permalink
Item468: fix, the displayed field value now gets properly rendered be…
Browse files Browse the repository at this point in the history
…fore. Added raw switch to the display macro, to switch of rendering

git-svn-id: http://svn.foswiki.org/trunk/DBConnectorPlugin@1421 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
EugenMayer authored and EugenMayer committed Dec 17, 2008
1 parent f89313d commit a097b0d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions data/System/DBConnectorPlugin.txt
Expand Up @@ -44,6 +44,7 @@ With the macro !%EDITFIELDBUTTON% you can let apear a button for editing a field
| _topic_ | Current topic | Sets the topic name of which you want to edit the field |
| _field_ | - | *required* Name of the field you want to edit |
| _type_ | "" | optional Type of the field. This is used to use different edit templates. Look *Customizing Field-Editor User Interface* for informations|

| _buttonName_ | $field | Sets the name of the button, which will be displayed to the user |
*Example:* !%EDITFIELDBUTTON{ field="samplefield2" }% -> %EDITFIELDBUTTON{ field="samplefield2" }%
---+++ Display a value in a topic
Expand All @@ -53,6 +54,7 @@ With the macro !%DISPLAYDBFIELD% you can let display the value of a field in a t
| _topic_ | Current topic | Sets the topic name of which you want to display the field |
| _field_ | - | *required* Name of the field you want to display |
| _format_ | _field_ | here you can use a format string, while !%VALUE% get replaced by the field value |
| _raw_ | 0 | if you set this to true, the result field will not be rendered, so no TML->HTML conversion |
*Example:* !%DISPLAYDBFIELD{ field="samplefield2" }% -> %DISPLAYDBFIELD{ field="samplefield2" }%
---++ Methods
---+++ getValues( $web, $topic, @fields ) -> ( %result )
Expand Down
8 changes: 7 additions & 1 deletion lib/Foswiki/Plugins/DBConnectorPlugin.pm
Expand Up @@ -598,12 +598,18 @@ sub _displayFieldValue {
$topic = $params->{'topic'} || $topic;
my $fieldname = $params->{'field'} || "";
my $format = $params->{'format'} || "";
my $raw = $params->{'raw'} || 0;

return "error, no field given" if ($fieldname eq "");

my %result = getValues($web,$topic,[$fieldname],0);
return "not defined" if(!defined %result);
my $fieldvalue = Foswiki::entityEncode($result{$fieldname});
my $fieldvalue = $result{$fieldname};
if($raw) {
$fieldvalue = Foswiki::entityEncode($fieldvalue);
} else {
$fieldvalue = Foswiki::Func::renderText( $fieldvalue, $web);
}
if($format ne "") {
$format =~ s/%VALUE%/$fieldvalue/g;
return $format;
Expand Down

0 comments on commit a097b0d

Please sign in to comment.