Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Incorporating a simple Ajax poll script on a silverstripe page


Go to End
Reply


9 Posts   3195 Views

Avatar
RonnieH

Community Member, 14 Posts

4 January 2010 at 2:29am

Hello there,

My question is the following:

I am trying to make the following poll work inside my Silverstripe website:
http://net.tutsplus.com/tutorials/javascript-ajax/creating-a-dynamic-poll-with-jquery-and-php/

The page on which I've tried to test this is:
www.astruggleforpeace.nl/polltest/

Obviously, the poll is not working. I tried the same thing on a simple HTML-page and it did work there:
http://www.crovax.net/

The portion of the page containing the poll is actually an included Sidebar. My guess is that the problem is that the php/javascript knows not where to write the results page to... but I'm not at all sure... I have no intimate knowledge of either php or javascript. I have told the PHP file: define('HTML_FILE', 'http://www.astruggleforpeace.nl/polltest/'); I have noticed that when I try to vote not only does nothing happen to the page, there are no results written to the .txt files that should hold the vote tally.

Oh, and in case anyone wonders: I've spent lots of time trying to make the Poll Extension for Silverstripe work. It wouldn't function at all... I wanted to have a poll functioning asap, so I figured there must be a faster way than trying to wrestle my way through the hard times the framework was giving me. Though I guess this might turn out equally troublesome... you'd think putting a decent poll on one's site should be simple enough. :-/

I realize this is not strictly a silverstripe question, but I guess you guys should be best equipped to explain how the whole framework using php and .SS files might prevent this poll from functioning... Thank you very much in advance for your time and trouble, have a nice day!

Kind regards,
Ronnie

Avatar
tobych

Community Member, 97 Posts

4 January 2010 at 8:09pm

"I have no intimate knowledge of either php..."

This might sound rude, but I honestly don't understand how you can expect to get your site working without knowing PHP well. Am I missing something? I guess it depends on what you mean by "intimate". I don't imagine solving your problem is particularly hard, but I can't help thinking you'd be better off finding someone to help. Given that it's PHP, and that your site might be a non-profit project, I'm sure you can find someone who knows PHP well to donate a few hours of their time.

Toby

Avatar
RonnieH

Community Member, 14 Posts

4 January 2010 at 8:37pm

Dear Toby,

You're probably right. I just like trying to get stuff to work myself if I think a few pointers in the right direction might do the trick, hence I was hoping someone here would recognize the problem and drop me a hint. When I'm thoroughly convinced it's hopeless to try, I'll resort to asking someone else to fix it. I suppose you could say I'm stubborn, and bothering people whom I shouldn't... Sorry for wasting your time.

Best,
Ronnie

Avatar
tobych

Community Member, 97 Posts

4 January 2010 at 9:13pm

Ronnie,

Thanks for your reply. Hey, I don't feel like my time was wasted: after all, I chose to spend time writing a response. And anyway, I'm only one person amongst many that might choose to respond to your question. And this is exactly the right place to ask it. It's just that every now and again I see a question from someone who at first sight doesn't appear to have the knowledge I would assume as necessary for even getting started with developing a web app, and I always wonder what the story is. Well, now I know yours. I'm similarly stubborn about some things. Cooking, for example, where getting someone to help isn't always possible! In your case though, I guess I felt a bit frustrated as I wanted to help you, and anyone else in your apparent position, but didn't know where to start, and still don't. Questions that spring to mind include: Have you bought the SS book? Have you worked through the tutorial on the website, at least as far as http://doc.silverstripe.org/doku.php?id=tutorial:3-forms ? I guess the problem anyone might have helping you is that you're asking for help even getting started, while at the same time talking about specific things that aren't working. I don't really understand how anyone could help you by providing a "hint" apart from: work through the tutorials, buy the book, read the book, and so on. I don't mean to be sarcastic here: I'm genuinely interested in your situation as your question, for me, falls into a bracket that - much as I want to help - I never quite know how to go about answering without worrying as coming across patronising or sarcastic.

Meanwhile, perhaps someone will provide an answer for you that is more useful.

Toby

Avatar
RonnieH

Community Member, 14 Posts

4 January 2010 at 10:15pm

Hey Toby,

Thanks for your reply. Had just woken up 2 minutes (in Europe) when I read your response before, so I was a tad groggy. :-)

Yes, I have at some point worked through the first few chapters of the tutorial. I am starting to think I should simply make the poll as it is described in chapter 3 of the tutorial, though I did kind of like the idea of having an Ajax poll... oh well. :-)

The thing with the poll in question is, it is something completely separate from Silverstripe... I'm not trying to cooperate with it because I thought implementing a ready-to-use script would make my life easier. It even writes its results to a flat text file rather than to the SS-database. But it appears the PHP script for it isn't working, and I figured this must be because it not working with regular html-files on the server but .ss files within the framework (since it works famously on a regular HTML-site).

Basically, I thought maybe this was a thing regularly encountered by many people trying to employ these sort of stand-alone ajax scripts on sites built around silverstripe, and thus that there might be a simple generic solution to the problem. But I'm guessing there was more optimism than realism in this supposition, so I'll have to find some other way. :-/

Kind regards,
Ronnie

Avatar
tobych

Community Member, 97 Posts

5 January 2010 at 1:30pm

If you want to use a PHP file like this within a SS site, you need to do two things:

1. Make sure SS is ignoring the file, ie not including it when it builds its manifest.
2. Make sure Apache processes the file directly, rather than it ending up going through main.php.

Both are covered in this thread:

http://silverstripe.org/customising-the-cms/show/258520

Toby

Avatar
tobych

Community Member, 97 Posts

6 January 2010 at 3:29pm

AJAX basics in SilverStripe here:

http://doc.silverstripe.org/doku.php?id=recipes:ajax_basics

Avatar
RonnieH

Community Member, 14 Posts

7 January 2010 at 4:47am

Hey Toby,

Haven't had the chance to try it yet, but I will soon. The link looks like exactly the sort of thing I need, I'll let you know when I get it to work, or get stuck. :-)

Thank you very much!

Cheers,
Ronnie

Go to Top