Last active
June 30, 2023 12:18
-
-
Save sashabeep/048e59ce2a001387e2d257f5f4d696cc to your computer and use it in GitHub Desktop.
List template variable modx evo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*usage: [[ list? &tvname=`param` &class=`myclass` &name=`myname` &docid=`N` ]] */ | |
$doc = isset($docid) ? $docid : $modx->documentIdentifier; | |
$class = isset($class) ? $class : ""; | |
$name = isset($name) ? $name : ""; | |
$input = $modx->getTemplateVar($tvname,'*',$doc)['value']; | |
$vals = explode("||",$input); | |
if(!empty($vals)){ | |
$out = '<select name="'.$name.'" class="'.$class.'">'; | |
foreach($vals as $k=>$v){ | |
$out.='<option value="'.$v.'">'.$v.'</option>'; | |
} | |
$out.= '</select>'; | |
return($out); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment