Sep 13 2006

Use in your own site

Posted by admin under Old ASP applications

Well, the meaning of PollMentor is of course for you to be able to use it on your own sites, so here's a breif descriptions on how to do it:

Depending on whether you are using some templating engine or not it will be slightly different, but the main things for you is to do some includes



<!--#include file="incpollmentor.asp"-->
<!--#include file="include_classes.asp"-->
<!--#include file="include_htmlgen.asp"-->

The include_htmlgen.asp functions are  supposed to generate the html for the poll, so basically you can do exactly like in pollmentor.asp



'Lets get the current poll...
Dim sContent
Dim oPoll
Set oPoll = new Poll
oPoll.Open(-1)


This way we open the active poll - and we can then use the

Html_GeneratePoll( oPoll,false,230)

function to get the html to be rendered. You can for example just

Response.Write(Html_GeneratePoll( oPoll,false,230))

on the right place of your page. The 230 is a parameter specifying the maximum table width for the poll - and you can change it of course. If you look in  the pollmentorres.asp, we call

Html_GeneratePoll(oPoll,true, 500)

Here we have more space (we are presenting the result in a bigger area on the page).

The second parameter - true/false - if fForceResult. For pollmentorres.asp we want to show the result of the poll, so we specify true. However in pollmentor.asp we first want to show the poll itself (allowing for voting) then show the result (in the same spot). The poll posts to itself so to speak, so pollmentor.asp will act both as showing the poll and presenting the result (after voting). This is easiest understood by running the DEMO  

So we specify fForceResult to false - and the Html_GeneratePoll will itself decide what to show (poll if not posting back) or result (if posting back - of course first adding the vote to the database).