Hi,
I am working on a grade module for EE and I have everything done except for a last bit of the template parsing.
I can get it to display the assignments, the points earned, the possible points, and the grade. However, there are some other things I want to have available like the total of all points earned, the total of points possible, and the person’s final grade.
I have got it working with PHP, but could really use someone with a good understanding of how template parsing works to aid me with these last few features.
Cheers! Zac
Here’s a quick overview:
$TMPL->tagdata is all the text inside your module tags unparsed.
$TMPL->tagparams is an array of the attributes of your module tag.
$TMPL->swap_var_single(tag, replacement, tagdata) is a helper function that will replace a single tag (one that has no closing complement) with your choice of text. You could write your own helper function if you wanted, but these ones are already written and work well.
$FNS->prep_conditionals(tagdata, array_of_variables) will look for variables inside curly tags for conditional statements (if, else, etc…) and replace the variable names found in the keys of the array with their values. This allows the template designer to add conditional statements that use variables you provide.
Before you return, depending on your circumstances you might need to do this:
$tagdata = str_replace(SLASH, '/', $tagdata);
Lastly, you exit the function by returning a string of the html you created.
return $tagdata;
If your module iterates through records, just copy the $TMPL->tagdata at the beginning of the loop, and append it to the result string.
$tagdata = '';
foreach($data as $d)
{
$tagdata_data = $TMPL->tagdata;
// do processing
$tagdata .= $tagdata_data;
}
// do more
return $tagdata;
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.