Will "the Mighty" Strohl

Survey Module: Using the Module Template

Module Templates

When a module developer incorporates the use of templates in their module, that opens up a door to give the power to redesign and skin the module that was never before possible. A designer could do many things, such as:

  • Rewriting the HTML
  • Incorporating skin class names
  • Adding or removing module content
  • Rearranginng the placement of module content
  • And more that I haven't even thought of yet...

I think this is one of the best features that any module has come up with to this date. However, there is one really big flaw in module templates. This flaw is the lack of standardization support in the DotNetNuke core. What does that mean? It mean that right now, everyone is doing this their own way. It also means that skinners have no way to include module templates into their skin packages. I think these features are probably on the way though. (I hope.)

Let's see an example...

Survey Module Template

The DNN Core Survey Module is one of the module incorporating the template feature. By default, the first view of the survey module shows the question, and a list of possible answers.

Survey Module - Default View

Once the visitor chooses an option, they are shown the results of the survey module up to that point (unless the results view is turned off in the settings).

Survey Module - Default Results

Notice that in the survey results, one of the peices of information is the total number of votes that were used to calculate the percentage. For many websites and use cases, this is not a big deal. However, there are many cases where one might not want the visitor to see this information. For example, a less-trafficked website owner may not want to know the number of visitors that voted. The template feature facilitates this need.

You can get to the module template in the module settings.

Survey Module - Module Settings

The default HTML markup for the template is as follows:

<table border="0" cellpadding="2" cellspacing="0" summary="Survey Results">
<tr>
<td valign="top" class="YourCompanyNameSurveyResults">
[SURVEY_OPTION_NAME]&nbsp;([SURVEY_OPTION_VOTES])
</td>
<td align="left" valign="top" class="Normal" nowrap="nowrap">
<img src="[SURVEY_OPTION_IMAGEPATH]/red.gif" width="[SURVEY_OPTION_GRAPH_WIDTH]"
border="0" height="15" alt="" />&nbsp;[SURVEY_OPTION_PERCENTAGE]%
</td>
</tr>
</table>

A small change in the code would remove the number of votes per option. Notice that the SURVEY_OPTION_VOTES token is missing.

<table border="0" cellpadding="2" cellspacing="0" summary="Survey Results">
<tr>
<td valign="top" class="YourCompanyNameSurveyResults">
[SURVEY_OPTION_NAME]
</td>
<td align="left" valign="top" class="Normal" nowrap="nowrap">
<img src="[SURVEY_OPTION_IMAGEPATH]/red.gif" width="[SURVEY_OPTION_GRAPH_WIDTH]"
border="0" height="15" alt="" />&nbsp;[SURVEY_OPTION_PERCENTAGE]%
</td>
</tr>
</table>

Now, when the page loads, the number of votes is no longer visible.

Survey Module - Altered Template

I hope that this demo let you realize the beginnings of the true power that comes from template-enabled modules. I encourage you to play with the templates for the modules that have them available to you.

Technorati Tags: , , , , , , ,



blog comments powered by Disqus