Author Topic: Droplet [[fieldcheck]] for validating Optionfield items  (Read 2564 times)

mr-fan

  • Guest
Droplet [[fieldcheck]] for validating Optionfield items
« 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


« Last Edit: April 18, 2013, 04:33:03 PM by mr-fan »

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: Droplet [[fieldcheck]] for validating Optionfield items
« Reply #1 on: November 23, 2010, 03:36:11 PM »
Very good Idea, Martin.

Brings some logic into modules 'Layout Fields'.

*thumbsup*

Regards,
Stefek
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden