Using Banners in mrInterview

In the scripting for mrInterview you can use the object IOM. This is a collection of all the properties of the current interview. Amongst the list of properties belonging to IOM there is a collection named “Banners”. In the routing of your intervew script (i.e. your MDD-file!) you can add elements to this collection. By doing this you just add a new banner to your interview screen. This banner will need to have a name and a text like:

IOM.Banners.AddNew("MyBanner","This is my banner")

As soon as you now run an interview you will find this banner above all questions in your script – given you do not use any template. It may look like:

First Banner
First Banner

This way you may add as many banners to the page as you want. If you want to get rid of them you can either remove them writing

IOM.Banners.Remove("MyBanner")

This will permanently remove the banner from the interview. If you want to reuse the banner later you as well just could set the text of the banner to be empty:

IOM.Banners["MyBanner"].Text=""

Please note the different brackets that need to be used in these two cases: the first one uses the rounded ones as this is a function call and the second one uses the squared brackets as it is addressing an element of a collection.

When you start dealing with templates you may use the “” tag to define the location where your banners should appear on the screen. This tag allows you to define the name of the banner that should be shown in the place of this tag in the template. You just need to define a “Name” for the banner:

IOM.Banners.AddNew("Titel","This is my title banner")

and in your template you write:

Name="Titel">Title

If you are unsure about this: the word “Title” between the opening and closing tag will of course not be shown when mrInterview renders a page for the respondent from your script. It is just helping you to locate the tag in the html page. If you prefer you could as well write the opening tag with the closing “/” inside the tag, i.e. as a self closing tag. However – you will know about this if you ever tried to create you own template – don’t forget to close the tag.

The following screenshot is showing a page from a survey using different banners on different places. This has been achieved by using some tables for the layout of the screen. As well the template does contain the call of a CSS file for enhancing the formatting capabilities and making the template itself more readable. The use of CSS files with mrInterview templates may be another post to come soon. For the moment being the example script, the template and all needed files will be attached to this post in order to allow you to try everything yourself and maybe start from this point for your own projects.

Banners with a template
Banners with a template

There are several banners on this page, each of those controlled in exactly the same way as described before:

IOM.Banners.AddNew("Titel","This is my Title banner")
IOM.Banners.AddNew("FactHeader","This is the question description")
IOM.Banners.AddNew("Fact","This is a categorical question")

For the second question in the little example questionnaire there are just some changes to these headers, reflecting the changed contents of the screen:

IOM.Banners["Titel"].Text=""
IOM.Banners["Fact"].Text="This is a numeric question"

The place for the banners is determined in the template file. You will find a table being defined in this template and the different objects needed for the layout are placed in the different cells of that table. For those items being introduced by the template class names have been defined in order to be able to apply the style settings to those elements. Even if you are not aware about how to deal with CSS settings the template should be not too difficult to understand.

For your convenience the whole project including all needed files is attached as banner. If you encounter any problem using these files please drop me a line.

Leave a Comment