TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

May 23, 2024, 07:08:51 PM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,197
  • Total Topics: 21,221
  • Online today: 67
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 39
  • Total: 39

[Block] Polls for TP/SMF - and associated SSI hack

Started by Thurnok, October 21, 2006, 07:21:13 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bigb

Is there some way of setting up a random array to display a different poll each time the block is refreshed.

randpollarray = new Array();
randpollarray[0] = 'Poll #';
randpollarray[1] = 'Poll #';
randpollarray[2] = 'Poll #';

ssi_showPoll(this would be the random are array#.0);
echo '

';

Thurnok

Sure... this of course assumes you already have a number of polls and you manually enter the ones you want as part of the random display into the array...

example:

// if you are using php version < 4.2.0, you need to seed the random generator
srand((float) microtime() * 10000000);

// change <postnum> to actual post numbers - this is your array of polls
$randpollarray = array(<postnum>, <postnum>, <postnum>...);

// grabs a random key from the array
$randpollkey = array_rand($randpollarray);

// get the postnum value from the random array element
$randpollvalue = $randpollarray[$randpollkey];

ssi_showPoll($randpollvalue);

bigb

Thanks

Works great thanks for the help and quick response.

funxlab

Quote from: Thurnok on January 24, 2007, 02:16:34 AM
Yes, when you make a new poll that you want displayed in a TP block on your frontpage, you will need to edit the php block and add the new post info to it.  You can have multiple polls within the same block as you can see from the example.  So you can add as many as you like, though I wouldn't recommend adding too many because that will make your page quite long.  You can of course replace previous ones with the new ones simply by replacing the post number.

Thank you Thurnok . But how I can find post number? :)
Regards,
Jim

Ken.

With the poll in question displayed, look at your browser address bar and you should see the post # an the end of the address string.
" If everything seems under control, you're not going fast enough." - Mario Andretti
Yesterday When I was Young.

funxlab

ken.kimbrell
That was a great help. Accept my regards.
Jim

Ken.

" If everything seems under control, you're not going fast enough." - Mario Andretti
Yesterday When I was Young.

Ken.

As noted in the Other Thread for this hack:

Just installed all of these poll hacks for my fresh upgrade of SMF 1.1.1 & TP 097 and it worked like a charm.
Used FireFox to vote with my 'test' user and it looks good to me.  :coolsmiley:
IE7 looks good too.

You can see two polls on the right side of my Forum

Ps: I do have one question; is there a way to insert a horizontal line between each poll when you display two or more in a single block?
With the Mirage Theme that is the current default on my forum it just doesnââ,¬â,,¢t look right with two in one blockââ,¬Â¦ not clearly defined enough to me anyways. :-\
" If everything seems under control, you're not going fast enough." - Mario Andretti
Yesterday When I was Young.

Thurnok

@ken
Yep... the example in the first post of this topic actually shows it. ;)


Ken.

Quote from: Thurnok on February 03, 2007, 03:47:27 AM
@ken
Yep... the example in the first post of this topic actually shows it. ;)

Strange how that works out... my code didn't have the < hr /> entry!  :2funny:
Thanks Thurnok
" If everything seems under control, you're not going fast enough." - Mario Andretti
Yesterday When I was Young.