Monday, December 10, 2007

Enhancing your Layout

Hopefully everyone had a chance to look at example1. Well now, I would like to change it. I had a comment on my blog about handling null values, so I thought I would address that in today's post. I have created example1a.xml to demonstrate how to handle a null phone number value and put a default value in it's place. You can then take the logic in the template and apply it wherever you need to.

Here is example1a.xml (you can download it from http://www.mediafire.com/?5qnnju1zg1i )



















But first I have to step back a second and explain a little more about our template file. For example1a, I took the .rtf file from example1 and enhanced it. You can download this template from http://www.mediafire.com/?9ocfbtmtzlp







From our previous example I have added a title, vendor phone column and combined the address, city, state and zip fields into one column. I have also removed the table borders using normal MS Word functionality to make the data look more 'report-like' rather than "table-like".
What I didn't discuss in our first example is that each field that was entered through our template-builder table/form menu has a "text form field options" box. If you double-click on VENDOR_PHONE you will get a box that looks like this :
















We have a lot of formatting and conditional options using this little option box!
If you click on the 'Add Help Text' button in the lower left hand corner you will
normally just see the XML tag from your data.xml file. This is how the XML data
is merged with the template.






So... I bet you're wondering how you enter a default value if our phone number just happens to be null. Am I right? In the same Text Form Field Options box, we can enter
<?if:VENDOR_PHONE=''?>Private Number<?end if?>
<?if:VENDOR_PHONE!=''?><?VENDOR_PHONE?><?end if?>



Just a note, you'll want to leave out any unnecessary white space when entering into this box because you are only allowed 138 characters.








When we run our example from the Previewer as PDF we will get the output below with our default value populated for BIPboy

0 comments: