I want to let my visitor to embed polls

Started by cong, August 31, 2008, 11:35:34 PM

Previous topic - Next topic

Kindred

[SiNaN],

You missed the point....   Cong wants that form to be used on OTHER sites.  The change that you made will change the display of the poll on the smf site itself...   it won't allow him to post an SMF poll as a block on another site.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

[SiNaN]

:)

Well, if I get things correctly, it will.

I've created a poll. Then on display template, there is poll shown and there is an embed code.

See how I produce the embed code:

  $embed = '
         <form action="' . $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . '" method="post" accept-charset="' . $context['character_set'] . '" style="margin: 0px;">
            <table>
               <tr>
                  <td colspan="2">';

   if ($context['poll']['allowed_warning'])
      $embed .= '
                     ' . $context['poll']['allowed_warning'] . '
                  </td>
               </tr><tr>
                  <td>';

   foreach ($context['poll']['options'] as $option)
      $embed .= '
                     ' . $option['vote_button'] . ' ' . $option['option'] . '<br />';

   $embed .= '
                  </td>
                  <td valign="bottom" style="padding-left: 15px;">';

   $embed .= '
                  </td>
               </tr><tr>
                  <td colspan="2"><input type="submit" value="' . $txt['smf23'] . '" /></td>
               </tr>
            </table>
         </form>';

   $embed = htmlspecialchars($embed);


Here is a sample of an embed code displayed in the topic besides poll options:

<form action="http://127.0.0.1/smf/index.php?action=vote;topic=7.0;poll=1" method="post" accept-charset="ISO-8859-1" style="margin: 0px;">
<table>
<tr>
<td colspan="2">
<input type="radio" name="options[]" id="options-0" value="0" class="check" /> Choice 1<br />
<input type="radio" name="options[]" id="options-1" value="1" class="check" /> Choice 2<br />
<input type="radio" name="options[]" id="options-2" value="2" class="check" /> Choice 3<br />
</td>
<td valign="bottom" style="padding-left: 15px;">
</td>
</tr><tr>
<td colspan="2"><input type="submit" value="Submit Vote" /></td>
</tr>
</table>
</form>


When you use that embed code on a usual html page, it will work. The point is, just you post the info to action=vote.
Former SMF Core Developer | My Mods | SimplePortal

Kindred

hmmmm.....   maybe I was wrong.

Of course, if guests can't vote, this won't work.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

cong

[SiNaN] you are great
Thank you very very much

you made me back to light

I tried with my 1.1.5 but guests can't vote but i need gusts to vote and i got many error message

so i download smf 2 now to test your tip on it

i will back and reply you when i test it on smf 2

cong

hey thank you very much sinan

you are very good

thank you also Kindred

The problem is solved

[SiNaN]

Former SMF Core Developer | My Mods | SimplePortal

cong

your tip is worked good but i found out small problem


i can't see poll question after embed code to external sit ( see the following image )



cong


[SiNaN]

We will, but you should a bit more patient. You know we are all valunteers here and trying to do our best. Bumping topics unless 24 hours passed from the last reply to topic is not a good idea really. :)

The codes I gave was for SMF 1.1.5. I thin you are trying to use them in SMF 2.0. Here what you should use in 2.0;

../Themes/default/Display.template.php

Find:

echo '
<table cellpadding="3" cellspacing="0" border="0" width="100%" class="tborder" style="padding-top: 0; margin-bottom: 2ex;">
<tr>
<td class="titlebg" colspan="2" valign="middle" style="padding-left: 6px;">
<img src="', $settings['images_url'], '/topic/', $context['poll']['is_locked'] ? 'normal_poll_locked' : 'normal_poll', '.gif" alt="" align="bottom" /> ', $txt['poll'], '
</td>


Replace:

$embed = '
<table>
<tr>
<td>
' . $context['poll']['question'] . '
<form action="' . $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . '" method="post" accept-charset="' . $context['character_set'] . '" style="margin: 0px;">
<table>
<tr>
<td colspan="2">
' . ($context['poll']['allowed_warning'] ? $context['poll']['allowed_warning'] . '
</td>
</tr><tr>
<td>' : '');

foreach ($context['poll']['options'] as $option)
$embed .= '
' . $option['vote_button'] . ' <label for="' . $option['id'] . '">' . $option['option'] . '</label><br />';

$embed .= ' </td>
<td valign="bottom" style="padding-left: 15px;">
</td>
</tr><tr>
<td colspan="2"><input type="submit" value="' . $txt['poll_vote'] . '" /></td>
</tr>
</table>
</form>
</td>
</tr>
</table>';

$embed = htmlspecialchars($embed);

echo '
<table cellpadding="3" cellspacing="0" border="0" width="100%" class="tborder" style="padding-top: 0; margin-bottom: 2ex;">
<tr>
<td class="titlebg" colspan="2" valign="middle" style="padding-left: 6px;">
<img src="', $settings['images_url'], '/topic/', $context['poll']['is_locked'] ? 'normal_poll_locked' : 'normal_poll', '.gif" alt="" align="bottom" /> ', $txt['poll'], '
</td>
      <td class="titlebg" valign="middle" style="padding-left: 6px;">
         Embed
      </td>


Find:

echo '
</td>
</tr>
</table>';


Replace:

echo '
</td>
      <td class="windowbg">
            <textarea rows="5" style="width: 400px;">' . $embed . '</textarea>
      </td>
</tr>
</table>';
Former SMF Core Developer | My Mods | SimplePortal

cong

ok thank you very much i saw you online put i didn't pm u as you said in your sig

so now i c what u say

thank you very much for your great help

SmittyNY

Check out JS-Kit.com. You can copy and paste their scripts in between HTML tags. [ html] [ /html] This is the easiest way I think.

Kindred

1- this is an old post that has already been solved
2- you didn't read...   he wants to post SMF polls from his forum on OTHER sites.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

cong

Quote from: [SiNaN] on September 05, 2008, 07:34:21 PM
We will, but you should a bit more patient. You know we are all valunteers here and trying to do our best. Bumping topics unless 24 hours passed from the last reply to topic is not a good idea really. :)

The codes I gave was for SMF 1.1.5. I thin you are trying to use them in SMF 2.0. Here what you should use in 2.0;

../Themes/default/Display.template.php

Find:

echo '
<table cellpadding="3" cellspacing="0" border="0" width="100%" class="tborder" style="padding-top: 0; margin-bottom: 2ex;">
<tr>
<td class="titlebg" colspan="2" valign="middle" style="padding-left: 6px;">
<img src="', $settings['images_url'], '/topic/', $context['poll']['is_locked'] ? 'normal_poll_locked' : 'normal_poll', '.gif" alt="" align="bottom" /> ', $txt['poll'], '
</td>


Replace:

$embed = '
<table>
<tr>
<td>
' . $context['poll']['question'] . '
<form action="' . $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . '" method="post" accept-charset="' . $context['character_set'] . '" style="margin: 0px;">
<table>
<tr>
<td colspan="2">
' . ($context['poll']['allowed_warning'] ? $context['poll']['allowed_warning'] . '
</td>
</tr><tr>
<td>' : '');

foreach ($context['poll']['options'] as $option)
$embed .= '
' . $option['vote_button'] . ' <label for="' . $option['id'] . '">' . $option['option'] . '</label><br />';

$embed .= ' </td>
<td valign="bottom" style="padding-left: 15px;">
</td>
</tr><tr>
<td colspan="2"><input type="submit" value="' . $txt['poll_vote'] . '" /></td>
</tr>
</table>
</form>
</td>
</tr>
</table>';

$embed = htmlspecialchars($embed);

echo '
<table cellpadding="3" cellspacing="0" border="0" width="100%" class="tborder" style="padding-top: 0; margin-bottom: 2ex;">
<tr>
<td class="titlebg" colspan="2" valign="middle" style="padding-left: 6px;">
<img src="', $settings['images_url'], '/topic/', $context['poll']['is_locked'] ? 'normal_poll_locked' : 'normal_poll', '.gif" alt="" align="bottom" /> ', $txt['poll'], '
</td>
      <td class="titlebg" valign="middle" style="padding-left: 6px;">
         Embed
      </td>


Find:

echo '
</td>
</tr>
</table>';


Replace:

echo '
</td>
      <td class="windowbg">
            <textarea rows="5" style="width: 400px;">' . $embed . '</textarea>
      </td>
</tr>
</table>';



This solution not working now after upgrade to the latest version SMF 2.0 Beta 4

i can't find now the codes in Display.template.php
so may be the solution need update

thank you in advance

cong

I found the difference between the latest two versions in things like
<h3 class="titlebg headerpadding">
instead of
<td class="titlebg" colspan="2" valign="middle" style="padding-left: 6px;">

but i am newbie to php and smf
so plz anyone modify sinan reply
http://www.simplemachines.org/community/index.php?topic=258947.msg1691993#msg1691993
to be working with the latest version  SMF 2.0 Beta 4
plz i need it

cong

please anyone tell me if my problem with the latest version is not understood

[SiNaN]

Please, do not bump your topics unless 24 hours passed from the last reply.

Display.template.php

Find:

echo '
</div>
</div>';
}

// Does this topic have some events linked to it?


Replace:

echo '
</div>
<h3 class="titlebg headerpadding">
<img src="', $settings['images_url'], '/topic/', $context['poll']['is_locked'] ? 'normal_poll_locked' : 'normal_poll', '.gif" alt="" align="bottom" />Embed Codes
</h3>
<div class="windowbg clearfix" id="poll_options">
', $embed,'
</div>
</div>';
}

// Does this topic have some events linked to it?


Find:

if ($context['is_poll'])
{


Replace:

if ($context['is_poll'])
{
      $embed = '
<table>
   <tr>
      <td>
         ' . $context['poll']['question'] . '
         <form action="' . $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . '" method="post" accept-charset="' . $context['character_set'] . '" style="margin: 0px;">
            <table>
               <tr>
                  <td colspan="2">
                     ' . ($context['poll']['allowed_warning'] ? $context['poll']['allowed_warning'] . '
                  </td>
               </tr><tr>
                  <td>' : '');

      foreach ($context['poll']['options'] as $option)
         $embed .= '
                     ' . $option['vote_button'] . ' <label for="' . $option['id'] . '">' . $option['option'] . '</label><br />';

      $embed .= '                  </td>
                  <td valign="bottom" style="padding-left: 15px;">
                  </td>
               </tr><tr>
                  <td colspan="2"><input type="submit" value="' . $txt['poll_vote'] . '" /></td>
               </tr>
            </table>
         </form>
      </td>
   </tr>
</table>';

   $embed = htmlspecialchars($embed);
Former SMF Core Developer | My Mods | SimplePortal

cong

thank u mr sinan for your reply but there is a problem

the code doesn't shown in scrolled textarea like the previous solution

you can see this image to state the problem



[SiNaN]

Sorry.

Now,

Find:

      ', $embed,'

Replace:

      <textarea rows="5" style="width: 400px;">', $embed,'</textarea>
Former SMF Core Developer | My Mods | SimplePortal

cong

thank you sinan

the last thing i want the code to be beside the poll not under the poll

Like the solution you did before in the previous version

as the image shown





[SiNaN]

Okay...

Find:

<div class="tborder marginbottom" id="poll">

Replace:

<table>
<tr>
<td style="width: 100%">
<div class="tborder marginbottom" id="poll">


Find:

      echo '
   </div>
   <h3 class="titlebg headerpadding">
      <img src="', $settings['images_url'], '/topic/', $context['poll']['is_locked'] ? 'normal_poll_locked' : 'normal_poll', '.gif" alt="" align="bottom" />Embed Codes
   </h3>
   <div class="windowbg clearfix" id="poll_options">
      <textarea rows="5" style="width: 400px;">', $embed,'</textarea>
   </div>
</div>';


Replace:

      echo '
   </div>
</div>
</td>
<td style="width: 50%;">
<div class="tborder marginbottom" id="poll">
   <h3 class="titlebg headerpadding">
      <img src="', $settings['images_url'], '/topic/', $context['poll']['is_locked'] ? 'normal_poll_locked' : 'normal_poll', '.gif" alt="" align="bottom" />Embed Codes
   </h3>
   <div class="windowbg clearfix" id="poll_options">
      <textarea rows="5" style="width: 400px;">', $embed,'</textarea>
   </div>
</div>
</td>
</tr>
</table>';
Former SMF Core Developer | My Mods | SimplePortal

Advertisement: