Forums / Setup & design / Request: how to place a poll on my site

Request: how to place a poll on my site

Author Message

Vivienne van Velzen

Friday 15 October 2004 4:40:30 am

I searched the documentation and the forums, but I can't figure out how to place a poll on my site. I'm using version 3.3-4 (3.3 release 4), and don't have the option to upgrade to 3.4 (which I heard has the option to include a poll-package).
I've visited some ezpublish sites who do have a poll system, so I'm thinking it's possible.
Just missing some documentation here =). Anyone kind enough to start the documentation on polls by answering my question?
TIA,

Vivienne

Andrei Barhatov

Saturday 16 October 2004 3:12:19 am

I had the similar problem, but I have solved it just now (I think) %]

My roadmap:

1) I have seen templates for forum, polls, etc. in setup\templates page and there are mentioned such classes as forum, poll & others. But in setup\classes there are no such classes therefore I can't create new content objects for them...
2) But also I can't see such functions as "register" or "switch on" forum, poll, etc. which must be in setup\packages page (as I thought).
3) So I do: <b>go to setup\packages, select addons item in list, select necessary addon, uninstall it and then install again</b>. And that's all - it works %]

Vivienne van Velzen

Sunday 17 October 2004 10:20:34 pm

Hi Andrei,

Thanks for replying. I'm feeling really stupid right now, but I still can't figure it out.
When I go to setup/packages/ all I can do is either 'import package' or 'create package'. When I click 'import package', I have to browse to a package file that I don't have (the poll), so that's not working. When I click 'create package', I can create packages with the classes that are already there (which makes sense), but poll isn't one of them.

When I go to kernel/setup/packages/ I don't see a poll package, just polls that are part of the news and blog packages. Do I have to import one of these packages to get the poll functionality? And what happens to the rest of my database when I import?

TIA for any answers given,

Vivienne

Andrei Barhatov

Sunday 17 October 2004 11:04:03 pm

Poll package is in ez/packages/addons/poll.

If "poll" class is not visible you should: in admin interface go to setup/packages, <b>select "addons" store from list</b>, select "poll" package from list and then deinstall it (if installed) and install again.

Vivienne van Velzen

Sunday 17 October 2004 11:35:23 pm

Hi Andrei,

Since I don't have the options you described, I'm thinking you're working with a different version of EZPublish. I'm working with version 3.3-4 (3.3 release 4), and don't have the opportunity to upgrade. So I'm looking for a poll package for this version.

Vivienne

Wenyue Yu

Tuesday 19 October 2004 2:10:52 am

Hi,

Four steps to set a poll for 3.3:
1. Create poll class 'poll' which has at least datatype 'option' and this datatype should be information collector.

2. Create an content object of class 'poll', set your options there.

3. Edit/Override collect.ini, uncomment TypeList[poll]=poll

4. Override result template design/standard/templates/content/datatype/result/count/ezoption.tpl ( optional )

Hope it helps!

Regards,
wenyue

Andrei Barhatov

Tuesday 19 October 2004 7:01:35 am

I'm beginner at ezp... what is <b>information collector</b>? I've seen such checkbox in definition of attributes, but what does it mean?

Wenyue Yu

Wednesday 20 October 2004 3:10:01 am

Hi,

Documentation about information collector can be found here http://ez.no/ez_publish/documentation/customization/components/information_collection

Regards,
wenyue

Vivienne van Velzen

Thursday 21 October 2004 11:47:29 pm

Hi Wenyue,

Thanks for the help, I'm almost there! I just got one more question.
I'm placing the poll as an inline element on my homepage. When someone votes, I'd like to redirect to the homepage (have changed the settings in collect.ini to do this). Then I'd have to detect if this person has voted, so I can show the results instead of the poll.
How do I detect if someone has voted?

Vivienne

Vivienne van Velzen

Thursday 21 October 2004 11:55:42 pm

O, and (since I can't seem to edit my previous post) how do I keep anonymous users from voting more than once?
TIA,

Vivienne

Łukasz Serwatka

Thursday 21 October 2004 11:58:30 pm

Hi,

I clicked "keep me updated" and since now i can edit your posts oO

Could somebody repair this?

Luke

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Łukasz Serwatka

Friday 22 October 2004 12:01:35 am

Sorry for duble posts, but everything is all right now

Strange thing

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Wenyue Yu

Friday 22 October 2004 12:39:52 am

Hi Vivienne,

To disable multiple votes, you can set CollectionUserDataList[poll] to 'unique' in collect.ini.

To detect whether or not a user has voted is a bit harder. I only know how can find that in php code

$collection =& eZInformationCollection::fetchByUserIdentifier( eZInformationCollection::currentUserIdentifier(), $object->attribute( 'id' ) );
if ( $collection )
    print( "user has voted" );
else
    print( "user has not voted" );

Regards,
wenyue

Vivienne van Velzen

Friday 22 October 2004 4:16:36 am

Hi Wenyue,

I'm completely happy now =). I didn't get the result on the homepage to work. I tried to use an external script to determine whether someone had voted already, but kept getting the error 'Cannot instantiate non-existent class: ezinformationcollection', even though I included the script from 'kernel/classes/ezinformationcollection.php'. So I settled for a seperate resultpage, which doesn't look too bad.

For anyone else who has the same question as I did, an overview of the steps I took (with thanks to Wenyue):

1. Create a 'Poll' class with at least a datatype 'Option' (check information collector)

2. Give anonymous users read-rights to this class

3. Create a content object with class 'Poll' and set your options

4. Override collect.ini(.append.php), in my case I used the following settings:
- TypeList[poll]=poll
- SendEmail=disabled
- DisplayList[poll]=result
- CollectAnonymousData=enabled
- CollectAnonymousDataList[poll]=enabled
- CollectionUserDataList[poll]=unique

5. Override the necessary templates. I used override templates for:
- full_class_poll.tpl (node/view)
- radiobutton layout in pollpage (content/datatype/collect/ezoption.tpl)
- resultpage (content/collectedinfo/poll.tpl)
- result imagebars (content/datatype/result/count/ezoption.tpl)

6. Set the override templates in override.ini.append.php

7. Tada!

Other comments:
- I added a 'visible' flag to my 'Poll' object, which I use to determine if a poll is still active.
- My version of Mozilla Firefox did not show the result imagebars. This was because in the default template, the '#' was missing before the backgroundcolor attribute of the table cell.

Thanks to all your help!
Vivienne

Vivienne van Velzen

Sunday 24 October 2004 11:21:42 pm

Hello (peeks head around corner)...?
I was a bit too enthousiastic in my last post, as I found another question...
If I allow anonymous users to vote, how do I prevent a user to vote more than once? With the configuration I showed in the last post, I can vote, but my colleague on the other computer (at another location and ip-address) gets the message that he already voted.
For now, I replaced 'CollectionUserDataList[poll]=unique' with 'CollectionUserDataList[poll]=multiple', but I would like some check to exists. Is there such a thing?
TIA,

Vivienne