Jump to:

22996 Posts in 11844 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » Incorporating a simple Ajax poll script on a silverstripe page

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

Page: 1 2
Go to End
Author Topic: 2838 Views
  • RonnieH
    Avatar
    Community Member
    14 Posts

    Incorporating a simple Ajax poll script on a silverstripe page Link to this post

    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

    Attached Files
  • tobych
    Avatar
    Community Member
    97 Posts

    Re: Incorporating a simple Ajax poll script on a silverstripe page Link to this post

    "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

  • RonnieH
    Avatar
    Community Member
    14 Posts

    Re: Incorporating a simple Ajax poll script on a silverstripe page Link to this post

    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

  • tobych
    Avatar
    Community Member
    97 Posts

    Re: Incorporating a simple Ajax poll script on a silverstripe page Link to this post

    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

  • RonnieH
    Avatar
    Community Member
    14 Posts

    Re: Incorporating a simple Ajax poll script on a silverstripe page Link to this post

    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

  • tobych
    Avatar
    Community Member
    97 Posts

    Re: Incorporating a simple Ajax poll script on a silverstripe page Link to this post

    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

  • tobych
    Avatar
    Community Member
    97 Posts
  • RonnieH
    Avatar
    Community Member
    14 Posts

    Re: Incorporating a simple Ajax poll script on a silverstripe page Link to this post

    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

    2838 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.