WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: mr-fan on November 21, 2010, 08:39:57 PM

Title: Droplet [[fieldcheck]] for validating Optionfield items
Post by: mr-fan on November 21, 2010, 08:39:57 PM
hi,

i haven't contributed some little pieces for a long time so here is a little droplet for checking field in Options from Newsmodule or Topics in my example:

Dropletname: fieldcheck

Code:

Code: [Select]
<?php //only for color dont copy
if (isset($field) and $feld != '') {
  if (isset(
$name)) {
      
$output '<strong>'.$name.'</strong>: '.$feld;   //maybe other output is wanted here
  
}else{
      
$output $feld;
  }
}else{
 
$output '&nbsp;';
}

return 
$output;

Examplecall: [[fieldcheck?field=[SHORT_DESCRIPTION]&name=Shorttext]]

Output would be like      "shorttext: Short_description"

example from Topics Options:
Code: [Select]
<h3 class="tp_headline_termine">{TITLE}</h3>
<p>[[fieldcheck?field=[SHORT_DESCRIPTION]&name=Was]]
[[fieldcheck?field=[XTRA2]&name=Wo]]
[[fieldcheck?field=[XTRA3]&name=Hinweise]]</p>
 [EDITLINK]

If the field is empty (like in Topics some XTRA fields) no output would be created or you could set a default output...

only a little piece of code btu mybe helpfully.

best regards

martin


Title: Re: Droplet [[fieldcheck]] for validating Optionfield items
Post by: Stefek on November 23, 2010, 03:36:11 PM
Very good Idea, Martin.

Brings some logic into modules 'Layout Fields'.

*thumbsup*

Regards,
Stefek