I really like this extensions, definitely glad I purchased the subscription because I can see there is a strong future for this.

My question is, how can I display some sort of message AFTER a user votes on a poll? My preference would be for a little AJAX section of text to automagically appear on the screen (not a popup) with a some sort of thank you message.

The message could be used to thank them for voting, to suggest related websites to visit for more information, to tell them when the next poll is being published, tell them how many points they just earned, etc. Lots of uses.

:!: Most important to me - It could let a poll be used as a very basic quiz and display the "right answer" from the poll choices after the vote. For example, have a True / False poll and the correct answer is displayed after the vote. Users can also then see how many people voted true or false in the poll results. See all the value that extra message creates? :D

Adding a simple text message in the process flow to display after a vote seems like a simple feature to add but would provide a lot of additional value to the polls. For me, it would eliminate any need for a separate quiz component. :idea: It gives you a new use case for promoting your component too.

:?: So how can I do this? Is there a hack or upgrade that can provide this feature? Thanks again for an excellent extension!
Like it on Facebook, Tweet it or share this topic on other bookmarking websites.
  • Re: simple text message to display AFTER a vote?

    by » 10 years ago


    A simple text message like Thank You etc can be easily displayed after voting completed. It is just a modification in few places.

    However if you need a quiz like solution that tells what is the right answer and what is not etc, then a good amount of changes requires both with the code as well as a minor database tweeks.

    I would suggest you to use full fledged Quiz components that will allow you to display unlimited questions. If you do not find any solution that you are looking for, we are developing a quiz/survey component which will be available in the next 3-4 months.

    If you want code tweeks in Community Polls itself, as I mentioned above, please let me know.

    Follow me on twitter: https://twitter.com/corejoomla
    If you use our extensions, please post a rating and a review at the Joomla! Extensions Directory.
    Sociable | Surveys | 
    CjForum | Polls | Answers | Quizzes | Quotes | GPS ToolsCjFit | CjBlog


  • Re: simple text message to display AFTER a vote?

    by » 10 years ago


    Hi Maverick,

    All I need is the simple text message capability. I want to be able to add an optional custom text message for each poll.

    One of the ways 'll use it is like a one-question Quiz, but it won't actually be a real Quiz feature, with grading of answers, etc. I'll use it in the poll to pose a question, such as "is the Earth flat?" True or False. then they answer the Poll, and in the text message I will tell them the answer, "Thanks for voting. The correct answer is Yes, the Earth is flat. Learn more at wikipedia". But I won't need scoring or anything like that. Actualy, forget that I mentioned quiz capability, because I don't want to confuse anything further. :)

    Everything I need to do can be accomplished with a simple text message that appears after the vote is submitted.

    So if you could please help me add a simple optional input for an optional text message, then help me to display it after a vote, I will be a delighted customer!
    :D
    Thanks,
    Dave

  • Re: simple text message to display AFTER a vote?

    by » 10 years ago


    Alright lets start with step by step(big one):

    1. First create the database column where you could attach your custom message
    ALTER TABLE `jos_jcp_polls` ADD COLUMN `custom_msg` VARCHAR(255);


    2. Get the data from the new column in poll creation page
    Find the below code in components/com_communitypolls/views/YOURTEMPLATE/tmpl/newpoll.php
                <tr>
    <th width="120px">
    <b><?php echo JText::_('LABEL_TITLE');?></b>:
    </th>
    <td>
    <input type="text" name="polltitle" id="polltitle" class="forminput"/>
    </td>
    </tr>


    ADD the below code after the above code
                <tr>
    <th width="120px">
    <b><?php echo JText::_('Custom Message');?></b>:
    </th>
    <td>
    <input type="text" name="custommsg" id="custommsg" class="forminput"/>
    </td>
    </tr>


    Basically we are adding another text box after title text box so that you can enter a custom message on creating new poll.

    3. Now add code to store the message in database
    Find the below code(function) in components/com_communitypolls/models/polls.php
    function &addNewPoll() {


    In that function you can find code to get the request variables something like below:
    $title = JRequest::getVar('polltitle','','post','STRING');


    Add the below line anywhere after or before such lines.
    $custom_msg = JRequest::getVar('custommsg', null,'post','STRING');


    4. Modify the SQL query to update the database values from your form
    Find below line in the same function shown above
    $query = 'INSERT INTO ' . TABLE_JCP_POLLS . '(title, alias, description, created,' .


    And replace it with below line
    $query = 'INSERT INTO ' . TABLE_JCP_POLLS . '(title, alias, description, created, custom_msg,' .


    Find below line just below the above one
    $db->Quote($description) . ',NOW(),' . $user->id . ',' . $category. ',' .

    Replace it with
    $db->Quote($description) . ',NOW(),' . $db->Quote($custom_msg) . ',' . $user->id . ',' . $category. ',' .


    5. Now your custom message is inserted in database. All you have to do is displaying the message on front-end after voting. So fetch the value along with other values once the vote done. Find the below code in models/polls.php at around line 440 in function getPollData
    $query = 'SELECT p.id, p.title, p.alias, p.description, p.votes, p.type,' .

    Replace it with
    $query = 'SELECT p.id, p.title, p.alias, p.description, p.votes, p.type, p.custom_msg,' .


    6. Since voting is done by Ajax call, you need to add the message in Ajax response. For this find the below line in components/controllers/polls.php
    $return .= "}else {
    <errormsg>Error: " . htmlspecialchars($model->getError()). "</errormsg>";

    Add the below code just ABOVE the line
    $return .= "<custommsg>htmlspecialchars($poll->custom_msg). "</custommsg>";


    7. Now the last step is to display it on the front-end. You can display using Javascript alert(easy one) or inline using some styles (need some more coding). I will guide you through both.
    File to edit: components/com_communitypolls/views/TEMPLATE/tmpl/viewpoll.php (based on template you are using the line numbers I am mentioning might differ slightly. I am using sirimalli template now)

    JavaScript Alert
    Find below line at around line 67
    updateWrapper();

    Add the below lines right after that
    var custom_msg = xmlDoc.getElementsByTagName('custommsg').item(0);
    alert(custom_msg);


    Inline Message
    Instead of alert(custom_msg) in line of code above you need to put the message in some div/span or paragraph tag. I am using div. For this you need to add the empty div tag at your desired place. May be just above your poll title or your cast vote button. I feel above cast vote button would be ideal and visible position. So find the below code at around line 216:
        <div id="resultchart" <?php echo ($this->poll->eligible)?'style="display: none"':''?>>
    <?php include_once JPATH_SITE . DS . 'components' . DS .
    'com_communitypolls' . DS . 'helpers' . DS . 'charts.php'; ?>
    </div>
    <div style="height: 10px;"></div>

    Add the below code right after that
    <div id="custom_msg" class="toolbar"></div>

    Of course you can use your custom style class instead of toolbar class I used above.

    Now replace the alert(msg) in Javascript method with the below code:
    var custom_msg_wrap=document.getElementById("custom_msg");
    custom_msg_wrap.innerText=custom_msg;


    There we go. Now your script is ready to accept and display your custom message. Please let me know in case you need any help.

    Follow me on twitter: https://twitter.com/corejoomla
    If you use our extensions, please post a rating and a review at the Joomla! Extensions Directory.
    Sociable | Surveys | 
    CjForum | Polls | Answers | Quizzes | Quotes | GPS ToolsCjFit | CjBlog


  • Re: simple text message to display AFTER a vote?

    by » 10 years ago


    THANKS SO MUCH MAVERICK!! :D :D And such a fast response! So glad I bought this from you. By the way, I provided a great review for you on JED several weeks ago also.

    I don't have time to implement tonight but I will try it this week.

    One other upgrade I was thinking of today...

    How can I also have the optional text message display in the poll results page, when someone is browsing the poll results? I'm thinking of using the Ajax feature you described above for the text instead of Javascript. I don't like the Javascript popups.

    Where could I add a little link or a +/- symbol or something like that, to display the message on the results screen? Like in the same way people hide and unhide comments. This way people reviewing the polls can get a reminder of what the closing text was. If they answer 25 polls, they will probably forget the messages from many of the polls, and so I'd like to be able to remind them by showing the text message again.

    Does that make sense? If you get some spare time, I'd really appreciate your guidance on that piece.

  • Re: simple text message to display AFTER a vote?

    by » 10 years ago


    Having +/- symbol to expand/hide the DIV tag we are displaying can be done using some simple javascript stuff and css styling. If you search in Google there are many resources that will guide you through this. Better option is to use MooTools itself.

    And when you first display the poll, you need to show the custom message in the same place where we are displaying when vote is cast. For that you need to change code mentioned in the Inline Message steps as shown below
        <div id="custom_msg" class="toolbar"></div>

    To
        <div id="custom_msg" class="toolbar"><?php echo $this->escape($this->poll->custom_msg); ?></div>

    Follow me on twitter: https://twitter.com/corejoomla
    If you use our extensions, please post a rating and a review at the Joomla! Extensions Directory.
    Sociable | Surveys | 
    CjForum | Polls | Answers | Quizzes | Quotes | GPS ToolsCjFit | CjBlog


You do not have permissions to reply to this topic.

Powered by CjForum

Trending Topics

Why is each share code for same poll different?
  • 0 replies
Hi there, My social media manager is telling me that she can't use...

Change the info that appears in WhatsApp share
  • 2 replies
Hi, Is it possible to change what appears when a poll is shared in...

embedded poll has no sharing options or picture
  • 3 replies
Hi, I'm testing out embedding a poll and it works, but votes are...

How to define the default editor?
  • 1 reply
Hi. Where can I define the default editor?Me and my visitors always...

How to install code on Wordpress site
  • 4 replies
Hi, I'm hoping someone can help me with this quickly as I need to...