Okay, enough promo- time to work.
We're going to make a component that decides wether or not the user would like a cookie.
$f->flatbox_header();
#or, if you haven't used the flatbox tutorial:
#print_comp_header("Cookie?");
"""<form action="$p.base_url" method="get">"""; #this makes our journal the action of the form
#Lets first see if someone already submitted to here.
if ($p.args{"cookie"} == "yes") { #the page class contains a hash "args". This is a named list basically, we want the element named "cookie"
"""You did like my cookie! Want another?<br/>""";
} elseif ($p.args{"cookie"} == "no") {
"""No? Are you sure?<br/>""";
} else { #If they have submitted this form yet...
"""Would you like a cookie?<br/>"""
}
"""<label for=".cookie">Yes</label><input type="radio" name=".cookie" value="yes"/><br/> #Note that the field on the form is named ".cookie", but the value used above was just "cookie".
#This is a requirement of S2.
#When making your own forms, follow this rule.
<label for=".cookie">No</label><input type="radio" name=".cookie" value="no"/><br/>
<input type="submit" value="Get your cookie."/>
</form>
""";
$f->flatbox_footer();
#or:
#print_comp_footer();