Page 1 of 1

Check this style

PostPosted: Wed Aug 22, 2007 11:27 am
by SrNupsen
Just wanted to share with you a crazy news style I made for my current developing project. Note that newlines will be converted to <br />, so everything except the PHP code needs to be kept on the same line.

Code: Select all
<If: Sub: isNewValue: CustomField_produktgruppe>
<a name="<Field: CustomField_produktgruppe>">
<tr><td colspan="6">&nbsp;</td></tr>
<tr class="overskrift_skjema"><td colspan="6"><Field: CustomField_produktgruppe></td></tr>
<tr><td colspan="6">&nbsp;</td></tr>
<tr><td>&nbsp;</td><td><b>Poser</b></td><td><b>Sjaktel</b></td><td colspan="3"><b>Kilo</b></td></tr>
</If>
<?php
$pose = rawurlencode ("<Field: CustomField_produktnavn> (pose)");
$sjaktel = rawurlencode ("<Field: CustomField_produktnavn> (sjaktel)");
$kilo = rawurlencode ("<Field: CustomField_produktnavn> (kilo)");
?>
<tr><td><Field: CustomField_produktnavn></td><td><input <?php if (!empty($errors[$pose])) { echo "style=\"border: 2px solid red;\" onmouseover=\"return overlib('Ugyldig verdi!');\" onmouseout=\"return nd();\" ";}?>type="text" name="<?=$pose?>" size="2" maxlength="3" value="<?php echo $_POST[$pose]; ?>"> à <Field: CustomField_produktpris_pose></td><td><input <?php if (!empty($errors[$sjaktel])) { echo "style=\"border: 2px solid red;\" onmouseover=\"return overlib('Ugyldig verdi!');\" onmouseout=\"return nd();\" ";}?>type="text" name="<?=$sjaktel?>" size="2" maxlength="3" value="<?php echo $_POST[$sjaktel]; ?>"> à <Field: CustomField_produktpris_sjaktel></td><td><input <?php if (!empty($errors[$kilo])) { echo "style=\"border: 2px solid red;\" onmouseover=\"return overlib('Ugyldig verdi!');\" onmouseout=\"return nd();\" ";}?>type="text" name="<?=$kilo?>" size="2" maxlength="3" value="<?php echo $_POST[$kilo]; ?>"> à <Field: CustomField_produktpris_kilo></td><td><EasyEdit: Edit></td><td><EasyEdit: Delete></td></tr>


You'll notice use of the IsNewValue addon to create gray headers for each product group (yes, it's actually an order form in Norwegian), along with the great Overlib library by Erik Bosrup to present mouseover descriptions of errors in input fields. Each field is repopulated using PHP code (if user typed something and then clicked OK - form validation).

I also spent a lot of time figuring out how to give the input fields a valid "name" attribute, as this is controlled by what my employee puts into the field "product_name". To make sure the name attribute doesn't contain any illegal characters, i use PHP's rawurlencode function.


You can see it in action by visiting http://www.noindexing.please/www.okourt ... oranto.php (replace 'www.noindexing.please' with 'luxor.domeneshop.no' ;) ) - try putting in some values, but MAKE SURE YOU MAKE SOME MISTAKES like putting letters instead of numbers. If you don't, you'll go to the validate sub which I haven't completed yet, so you'll only see a blank page :)


I think it's yet another example of how everything can be done with Coranto. The whole point of this form is (of course) that the admin can edit, delete and add products and prices from within Coranto, and that the order form will update itself accordingly. If he or she is logged in to Coranto, he/she will even see small "Edit" and "Delete" buttons next to each item, thanks to Parahead's EasyEdit addon.

PostPosted: Wed Aug 22, 2007 1:15 pm
by Jackanape
Sweet! Now, there's something I never thought of!

PostPosted: Thu Oct 25, 2007 11:42 pm
by Rocky
Working link? I can't get that to work, even if when doing that frustrating url substitution. :evil:

PostPosted: Fri Oct 26, 2007 12:53 am
by SrNupsen
Tough luck... My employer asked me to take it down, as they won't be using that version. But The site is still being developed at http://dev.okourt.no

Sorry for tricking you into URL manipulation to no avail

SrNupsen :lol: