Vote for president!

Mods, snippets and styles postet and supported by the users
Forum rules
As the forum title says this is for User Contributions
Post a support request in this forum and you will be banned!
User avatar
Solidjeuh
BBCoder IV
BBCoder IV
Posts: 257
Joined: 16 Oct 2011, 00:15
BBCodes: 7
Favourite MOD: Top stats
Location: Aalst / Belgium

Vote for president!

Post by Solidjeuh » 02 Oct 2012, 03:10

This is the 'Vote for president' snippet.
This is not mine! I grabbed part of the code from the Board3 portal random member module.

------------------------------------------

open index.php

Find:

Code: Select all

// Assign index specific vars
Add before:

Code: Select all

		switch ($db->sql_layer)
		{
			case 'postgres':
			$sql = 'SELECT *
				FROM ' . USERS_TABLE . '
				WHERE user_type <> ' . USER_IGNORE . '
				AND user_type <> ' . USER_INACTIVE . '
				ORDER BY RANDOM()';
			break;

			case 'mssql':
			case 'mssql_odbc':
			$sql = 'SELECT *
				FROM ' . USERS_TABLE . '
				WHERE user_type <> ' . USER_IGNORE . '
				AND user_type <> ' . USER_INACTIVE . '
				ORDER BY NEWID()';
			break;

			default:
			$sql = 'SELECT *
				FROM ' . USERS_TABLE . '
				WHERE user_type <> ' . USER_IGNORE . '
				AND user_type <> ' . USER_INACTIVE . '
				ORDER BY RAND()';
			break;
		}

		$result = $db->sql_query_limit($sql, 1);
		$row = $db->sql_fetchrow($result);

        $username = $row['username'];
		$user_id = (int) $row['user_id'];
		$colour = $row['user_colour'];

		$template->assign_block_vars('random_member', array(
			'USERNAME_FULL'		=> get_username_string('full', $user_id, $username, $colour),
			'USERNAME'			=> get_username_string('username', $user_id, $username, $colour),
			'USER_COLOR'		=> get_username_string('colour', $user_id, $username, $colour),
		));
		$db->sql_freeresult($result);
Open: /styles/prosilver/template/index_body.html

Place wherever you want it ti show:

Code: Select all

<!-- BEGIN random_member -->
<p>Vote <span style="font-weight:bold; ">{random_member.USERNAME_FULL}</span> for President!</p>
<!-- END random_member -->
Screenshot:
2014-12-24 00 43 09.png
You do not have the required permissions to view the files attached to this post.
Last edited by Solidjeuh on 23 Dec 2014, 23:43, edited 2 times in total.
Yeah I'm crazy.. So What!?! Live Your Life The Way You Want It To be!
Download +30.000 arcade extension games @ ~ http://www.froddelpower.be ~


User avatar
martin123456
BBCoder VI
BBCoder VI
Posts: 764
Joined: 25 Jul 2011, 11:29
BBCodes: 34
Favourite MOD: Ban button
Location: Down south!

Vote for president!

Post by martin123456 » 02 Oct 2012, 03:13


User avatar
Solidjeuh
BBCoder IV
BBCoder IV
Posts: 257
Joined: 16 Oct 2011, 00:15
BBCodes: 7
Favourite MOD: Top stats
Location: Aalst / Belgium

Vote for president!

Post by Solidjeuh » 02 Oct 2012, 03:15

martin123456 wrote:You mean this one ? viewtopic.php?f=40&t=1977&p=12679&hilit=+vote#p12679
I tried that one.. Not working on my forum..
This code is a little different, and it works.. :roll:
This one also grabs the color of the group the user is in.. :D
Yeah I'm crazy.. So What!?! Live Your Life The Way You Want It To be!
Download +30.000 arcade extension games @ ~ http://www.froddelpower.be ~

User avatar
Stoker
Site Admin
Site Admin
Posts: 3511
Joined: 12 May 2008, 21:26
BBCodes: 239
Favourite BBCode: Anipro
Favourite MOD: PrettyPhoto
Location: Denmark

Vote for president!

Post by Stoker » 02 Oct 2012, 06:14

Code works perfect, its what I use here.
BTW, my code is also from the b3 portal random member :D
Board rules! No PM support
Sure, I can install the Mod for you ;)
Like the site? Then buy me a bear

User avatar
Steve
BBCoder VI
BBCoder VI
Posts: 803
Joined: 04 Mar 2010, 23:10
Extra Rank: Donator.png
BBCodes: 2000
Favourite BBCode: porn tube
Favourite MOD: Non of Stokers
Location: up your bum

Vote for president!

Post by Steve » 04 Oct 2012, 18:21

No need to use a switch for database types just also use $db->build_sql_query()
NAPWR wrote: Nice, Stoker is Hot


User avatar
RMcGirr83
BBCoder III
BBCoder III
Posts: 104
Joined: 08 Mar 2010, 11:17
Favourite MOD: mChat

Vote for president!

Post by RMcGirr83 » 05 Oct 2012, 10:01

That switch is needed for the different databases RANDOM function which ever it may be. (ORDER BY RANDOM()';ORDER BY NEWID()';ORDER BY RAND()';)

User avatar
Mindful Person
BBCoder I
BBCoder I
Posts: 2
Joined: 25 Jul 2014, 21:40
BBCodes: 16

Vote for president!

Post by Mindful Person » 26 Jul 2014, 07:06

Can this code show only members from a specific group?

User avatar
martin123456
BBCoder VI
BBCoder VI
Posts: 764
Joined: 25 Jul 2011, 11:29
BBCodes: 34
Favourite MOD: Ban button
Location: Down south!

Vote for president!

Post by martin123456 » 26 Jul 2014, 10:27

Mindful Person wrote:Can this code show only members from a specific group?

viewtopic.php?f=40&t=1977&p=12679&hilit=+vote#p12679

User avatar
Mindful Person
BBCoder I
BBCoder I
Posts: 2
Joined: 25 Jul 2014, 21:40
BBCodes: 16

Vote for president!

Post by Mindful Person » 26 Jul 2014, 14:11

I dont need it anymore.
Thanks anyway Martin I have found the solution.