apeisa Posted November 20, 2012 Share Posted November 20, 2012 I just pushed a new module to Github. I really liked Soma's idea (and execution!) to learn new frontend stuff while building useful modules to PW. While Soma is learning Knockout, I actually find AngularJS more interesting. So here is my first "AngularJS-powered" module: FieldtypePoll. This is simple polling fieldtype for (not so serious) votings like: Q: How is the weather today? a) Fine b) Rainy c) I don't know, been coding all day This should be all usable already, so if you are adventurous and want to help me debug, this is how to get started: 1. Grab the code -> https://github.com/a...a/FieldtypePoll (actual fieldtype and inputfield) -> https://github.com/apeisa/AngularJS (AngularJS and AngularUI for PW) 2. Install the FieldtypePoll module 3. Create new field, choose "Poll" as a new fieldtype 4. Add field to a template 5. Edit your template file, output the field: echo $page->whatEverNameYouGaveInStep3 6. Add some css: .PollApe .percentage { background: black; font-size: 10px; min-width: 5px; border-radius: 4px; padding: 4px 8px; text-align: right; color: white; margin-bottom: 0.6em; } .PollApe .PollApeTotalVotes { border-top: 1px solid #ccc; } 11 Link to comment Share on other sites More sharing options...
apeisa Posted November 20, 2012 Author Share Posted November 20, 2012 Oh, and few things I would like to add: Voting only for logged in users and once per user Vote multiple options Create more than one poll per page (or at least archive old ones) Better "have you voted yet" -checking. Not sure which would be best way to go and not looking for anything bulletproof here Using some csrf-token to avoid super easy "hacking". 2 Link to comment Share on other sites More sharing options...
Soma Posted November 20, 2012 Share Posted November 20, 2012 Yu knocked me out! 1 Link to comment Share on other sites More sharing options...
Pete Posted November 20, 2012 Share Posted November 20, 2012 Holy crap - cool module but also this is the first I heard of AngularJS and their demos on the project's homepage are pretty cool! Link to comment Share on other sites More sharing options...
apeisa Posted November 20, 2012 Author Share Posted November 20, 2012 It is supercool. Be sure the check these short tutorials from Youtube: https://www.youtube.com/watch?v=IRelx4-ISbs 2 Link to comment Share on other sites More sharing options...
Pete Posted November 20, 2012 Share Posted November 20, 2012 My mind is now officially blown. I'm sure I might even understand it more thoroughly when I've had some sleep Link to comment Share on other sites More sharing options...
fmgujju Posted May 13, 2013 Share Posted May 13, 2013 Apeisa: Is your module FieldtypePoll ready for production use? I was looking into Modules page on the main website but couldn't find anything about this module. Link to comment Share on other sites More sharing options...
apeisa Posted May 13, 2013 Author Share Posted May 13, 2013 I am using it on one site, but would love to polish it a little bit. Try and give some feedback, I am happy to hear how it goes. Link to comment Share on other sites More sharing options...
bfncs Posted May 13, 2013 Share Posted May 13, 2013 Very nice, I also played a little with Angular lately and it's a pretty neat tool, so it's very nice to have it packaged up as a Processwire module already. I'm definitely looking into FieldtypePoll later, looks really promising. Link to comment Share on other sites More sharing options...
Manol Posted May 13, 2013 Share Posted May 13, 2013 Fantastic apeisa, I'll give it a try, angularjs is awesome, in my opinion is more natural than backbone although finding some difficulties to make it work with jquerymobile. I'll try to learn from your code and give you some feedback. Link to comment Share on other sites More sharing options...
teppo Posted June 13, 2013 Share Posted June 13, 2013 (edited) @apeisa: I'm trying to use this on a PW 2.3 site and everything seems to work from administration point of view, but so far all I'm getting is this error message when I try to echo $page->my_poll (my_poll being the name of the field) on frontend: Fatal error: Call to a member function loadPageField() on a non-object in /example_com/wire/core/Page.php on line 651 Any idea what could be causing this? I'll probably try to debug it properly later, but not being exactly familiar with fieldtypes / inputfields doesn't really help here.. Edit: reinstalling FieldtypePoll and InputfieldPoll fixed the problem. There was something strange with the install process originally (autoinstall didn't work for InputfieldPoll, installing FieldtypePoll before AngularJS caused errors etc.) so this should've been pretty obvious solution. Anyway, problem solved and everything seems to work now, sorry for the confusion PS. Have you considered adding this to the modules directory? Seems like a nice addition there. Edited June 14, 2013 by teppo 1 Link to comment Share on other sites More sharing options...
awebcreature Posted June 15, 2013 Share Posted June 15, 2013 Thank you, Apeisa! Good job! Link to comment Share on other sites More sharing options...
jacknails Posted November 9, 2013 Share Posted November 9, 2013 Amazing work apeisa. I had a poll up and ready within minutes! Would it be possible to have a "View Results" link at the bottom of the poll? That way a user could see the results and then have a link "Back to Poll" if he'd like to vote. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now