So I realize I could’ve done this with pure HTML but in order to make it more dynamic and also to help sharpen my own coding, I decided to try and write a snippet instead.
The goal was to supplement and complete an Employee of the Month creation form. I’m using formIt and have three textfields (one RichText), and an image upload. The goal of my snippet was to dynamically create a dropdown for month selection, as well as keep the month’s number value so I could later use it to arrange the awards in a blog like page. Also, it would just take the current year and pass that on just for the sake of getting that in there. The reason for the date specifically with the month widget is that they’re both for date so better to keep those together - especially if I want to transfer it’s usage later on.
But anyways...the code makes ModX freeze up...ModX stopped itself after it’s parser went nuts on the snippet. I tried installing it on a different ModX test site and still no luck...here’s my code.
<?php
$year = date('Y');
$iTpl=$modx->getOption('iTpl',$scriptProperties,'EoM_Inner');
$oTpl=$modx->getOption('oTpl',$scriptProperties,'EoM_Outer');
$selClass=$modx->getOption('selClass',$scriptProperties);
$selName=$modx->getOption('selName',$scriptProperties);
$months= array (
1 => 'January',
2 => 'February',
3 => 'March',
4 => 'April',
5 => 'May',
6 => 'June',
7 => 'July',
8 => 'August',
9 => 'September',
10 => 'October',
11 => 'November',
12 => 'December'
);
$x = 1;
for ($months[x]; x <= 12; $x++) {
$properties = array (
'year' => $year,
'month' => $months[$x],
'monthNum' => $x,
);
$menu .= $modx->parseChunk($iTpl, $properties);
}
$output = $modx->parseChunk($oTpl, array('menu'=>$menu,'selClass'=>$selClass,'selName'=>$selName));
return $output;
iTpl:
<option value="[[+monthNum]]">[[+month]]</option>
oTpl:
<select name="[[+selName]]" class="[[+selClass]]">[[+menu]]</select>
If you guys could help me here that’d be awesome. I’m doing this for my most technically developed site yet, and the more I’ve developed this site the more I realize I have trouble with. So all help is appreciated and a good learning experience