Vote for president!

Modifications for phpBB3.
Try the Mods here and share Your own Mods
Forum rules
You dont have to use ModX or make your mod AutoMod compatible. A simple textfile is fine
But if you post Mods here You also have to give support

Vote for president!

Post by Solidjeuh »

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.

Vote for president!

Post by martin123456 »

Vote for president!

Post by Solidjeuh »

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

Vote for president!

Post by Stoker »

Code works perfect, its what I use here.
BTW, my code is also from the b3 portal random member :D

Vote for president!

Post by Steve »

No need to use a switch for database types just also use $db->build_sql_query()

Vote for president!

Post by RMcGirr83 »

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

Vote for president!

Post by Mindful Person »

Can this code show only members from a specific group?

Vote for president!

Post by martin123456 »

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

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

Vote for president!

Post by Mindful Person »

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