Avatar's in Feature Carousel,

Hulp nodig bij je installatie of kom je ergens niet uit? Probeer phpBB3! Problemen lossen we samen met je op.
phpBB 3.0 is End of support per 1 januari 2017. Dit forum is hier enkel ter archief. Het wordt aangeraden te upgraden naar phpBB 3.2
Forumregels
phpBB 3.0 is End of support per 1 januari 2017. Dit forum is hier enkel ter archief. Het wordt aangeraden te upgraden naar phpBB 3.2
Gesloten
Gerard316
Berichten: 56
Lid geworden op: 21 sep 2007, 22:01

Avatar's in Feature Carousel,

Bericht door Gerard316 » 08 dec 2013, 17:54

  • phpBB versie:
    Laatste versie
Op mijn website heb ik een Feature Carousel en graag zou ik hier alle avatar's willen weergeven incl rankname.
Feature Carousel staat al online op mijn website (vraag link via pm) alleen daar moet ik handmatig de link+rankname+avatar zelf invoeren.

Op mijn test domein (vraag link via pm) probeer ik dat het automatisch de avatar pakt van een gebruiker met de rankname erbij.

overall_header.hml

Code: Selecteer alles

<!-- INCLUDE avatar-slider.html -->
avatar-slider.html

Code: Selecteer alles

    <div class="carousel-container">
    
      <div id="carousel">
		<div class="carousel-feature">
			<a class="thumbnail" href="{U_VIEW_PROFILE}"><!-- IF USER_AVATAR -->{USER_AVATAR_THUMB}<!-- ELSE --><span><img src="{T_THEME_PATH}/images/no_avatar.gif" alt="{USER_AVATAR}" width="105" height="125" /></span><!-- ENDIF --></a>
				  <div class="carousel-caption">
					<p>
					  {RANKNAME}
					</p>
				  </div>
		</div>
		<div class="carousel-feature">
			<a class="thumbnail" href="{U_VIEW_PROFILE}"><!-- IF USER_AVATAR -->{USER_AVATAR_THUMB}<!-- ELSE --><span><img src="{T_THEME_PATH}/images/no_avatar.gif" alt="{USER_AVATAR}" width="105" height="125" /></span><!-- ENDIF --></a>
				  <div class="carousel-caption">
					<p>
					  {RANKNAME}
					</p>
				  </div>
		</div>
		<div class="carousel-feature">
			<a class="thumbnail" href="{U_VIEW_PROFILE}"><!-- IF USER_AVATAR -->{USER_AVATAR_THUMB}<!-- ELSE --><span><img src="{T_THEME_PATH}/images/no_avatar.gif" alt="{USER_AVATAR}" width="105" height="125" /></span><!-- ENDIF --></a>
				  <div class="carousel-caption">
					<p>
					  {RANKNAME}
					</p>
				  </div>
		</div>
      </div>
    
      <div id="carousel-left"><img src="/styles/GamingClan/theme/images/avatar-slider/theme/ArrowRight.png" /></div>
      <div id="carousel-right"><img src="/styles/GamingClan/theme/images/avatar-slider/theme/ArrowLeft.png" /></div>
    </div>
avatar-slider.php

Code: Selecteer alles

Hier ben ik mee bezig! [u]zie probleem[/u]
Mijn probleem is eigenlijk het opvragen naar user_avatar en rankname. Hoe doe ik dit precies?
Ik ben hier al een paar dagen mee bezig maar zonder resultaat.


Wie o wie zou mij kunnen helpen?

Gebruikersavatar
Theriddler
Berichten: 1103
Lid geworden op: 20 apr 2012, 07:47
Contacteer:

Re: Avatar's in Feature Carousel,

Bericht door Theriddler » 08 dec 2013, 19:01

Wijziging: post kan weg niet meer relevant

-Theriddler

Gerard316
Berichten: 56
Lid geworden op: 21 sep 2007, 22:01

Re: Avatar's in Feature Carousel,

Bericht door Gerard316 » 08 dec 2013, 19:55

Bedankt voor jou snelle antwoord,

Ik heb de stappen uitgevoerd en als resultaat krijg ik in tekst {USERS_RANK_TITLE} en {USERS_AVATAR}.
Heb ik avatar-slider.php nog nodig..daar staat nog niks in namelijk?

Gebruikersavatar
Theriddler
Berichten: 1103
Lid geworden op: 20 apr 2012, 07:47
Contacteer:

Re: Avatar's in Feature Carousel,

Bericht door Theriddler » 08 dec 2013, 21:01

draai alles maar terug wat ik hierboven had gedaan ,ik ben even aan het kijken hoe of wat

Probeer het volgende

Maak een nieuw bestand aan en noem het avatar-slider.php met als inhoud:

Code: Selecteer alles

<?php
/**
*
* @package phpBB3
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*/
/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

if (!function_exists('get_user_avatar'))
 {
 include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
 }

$random_users = array();

$sql = 'SELECT *
				FROM ' . USERS_TABLE . '
				WHERE user_type <> ' . USER_IGNORE . '
				AND user_type <> ' . USER_INACTIVE . '
				ORDER BY RAND()';
        $result = $db->sql_query_limit($sql, 1);
		while ($row = $db->sql_fetchrow($result))
		{
			$random_users[$row['user_id']] = array(
				'user_id'				=> $row['user_id'],
				'username'				=> $row['username'],
     			'user_colour'			=> $row['user_colour'],
				'user_avatar'   		=> $row['user_avatar'],
				'user_avatar_type'   	=> $row['user_avatar_type'],
				'user_avatar_width'   	=> $row['user_avatar_width'],
				'user_avatar_height'	=> $row['user_avatar_height'],
				'user_rank'				=> $row['user_rank'],
				'user_posts'			=> $row['user_posts'],
			);
		}
		$db->sql_freeresult($result);
		
		foreach ($random_users as $row)
	{
		$username_string = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
		$user_avatar = ($row['user_avatar']) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], ($row['user_avatar_width'] > $row['user_avatar_height']) ? 75 : (75 / $row['user_avatar_height']) * $row['user_avatar_width'], ($row['user_avatar_height'] > $row['user_avatar_width']) ? 75 : (75 / $row['user_avatar_width']) * $row['user_avatar_height']) : '<img src="/images/avatars/no_avatar.gif" width="75px;" height="75px;" />';
		$rank_title = $rank_img = '';
        get_user_rank($row['user_rank'], $row['user_posts'], $rank_title, $rank_img, $rank_img_src);

		$template->assign_block_vars('random_member',array(
			'U_VIEW_PROFILE' 	=> append_sid($phpbb_root_path . 'memberlist.' . $phpEx, array('mode' => 'viewprofile', 'u' => $row['user_id'])),
			'AVATAR_IMG'  		=> $user_avatar,
			'USERNAME_FULL'		=> $username_string,
			'RANK_TITLE'		=> $rank_title,
			));
	}

$template->set_filenames(array(
   'body' => 'avatar-slider.html')
);

page_footer();
?>
upload deze naar de root van je forum

De template plaats je in de template map en noem je avatar-slider.html

Code: Selecteer alles

<div class="carousel-container">
       <!-- BEGIN random_member -->
          <div id="carousel">
          <div class="carousel-feature">
             <!-- IF random_member.AVATAR_IMG --><a class="thumbnail" href="{random_member.U_VIEW_PROFILE}">{random_member.AVATAR_IMG}</a><!-- ENDIF -->
                  <div class="carousel-caption">
                   <p><!-- IF random_member.RANK_TITLE -->{random_member.RANK_TITLE}<!-- ENDIF --></p>
                  </div>
          </div>
         <!-- END random_member -->
          </div>
          <div id="carousel-left"><img src="/styles/GamingClan/theme/images/avatar-slider/theme/ArrowRight.png" /></div>
          <div id="carousel-right"><img src="/styles/GamingClan/theme/images/avatar-slider/theme/ArrowLeft.png" /></div>
        </div>
Getest
Wijziging: codewijziging

-Theriddler

Gebruikersavatar
John P
Berichten: 163
Lid geworden op: 29 sep 2012, 13:48
Contacteer:

Re: Avatar's in Feature Carousel,

Bericht door John P » 09 dec 2013, 00:00

Zet in functions.php in de page_header function voor // The following assigns all _common_ variables that may be used at any point in a template. je query

Code: Selecteer alles

if (!function_exists('get_user_avatar'))
 {
 include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
 }
    $sql = 'SELECT u.user_id, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, r.rank_title 
            FROM ' . USERS_TABLE . ' u
            LEFT JOIN ' . RANKS_TABLE . ' r ON (r.rank_id = u.user_rank)
            WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')
            ORDER BY user_id';
                    
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result))
    {      
        $template->assign_block_vars('useravatar', array(
                'USERS_AVATAR'      => get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']),
                'U_VIEW_PROFILE'    => $row['user_id'],
                'USERS_RANK_TITLE'    => $row['rank_title']
        ));
    }
    $db->sql_freeresult();
 
Neem daarna op de juiste plaats (waarschijnlijk overall_header.html) de volgende code op:

Code: Selecteer alles

    <div class="carousel-container">
<div id="carousel">
    	<!-- BEGIN useravatar -->
			<div class="carousel-feature">
				<a href="/memberlist.php?mode=viewprofile&u={useravatar.U_VIEW_PROFILE}"><!-- IF useravatar.USERS_AVATAR -->{useravatar.USERS_AVATAR}<!-- ELSE --><span><img src="{T_THEME_PATH}/images/no_avatar.gif" alt="Avatar" width="105" height="125" /></span><!-- ENDIF --></a>
					  <div class="carousel-caption">
						<p>
						  {useravatar.USERS_RANK_TITLE}
						</p>
					  </div>
            <!-- END useravatar -->
			</div>
		</div>
    
      <div id="carousel-left"><img src="/styles/GamingClan/theme/images/avatar-slider/theme/ArrowRight.png" /></div>
      <div id="carousel-right"><img src="/styles/GamingClan/theme/images/avatar-slider/theme/ArrowLeft.png" /></div>
    </div>
Afbeelding
Webhosting, Custom MODs, Technical management, MOD installation and Webdesign

Gerard316
Berichten: 56
Lid geworden op: 21 sep 2007, 22:01

Re: Avatar's in Feature Carousel,

Bericht door Gerard316 » 09 dec 2013, 03:00

Beide mensen bedankt!

Gesloten