Eigener Block: Statistik Center-Block

Post Reply

Topic author
Mr Strech
Active Member
Posts: 29
Joined: 29. December 2009 16:25
phpBB.de User: Mr Strech

Eigener Block: Statistik Center-Block

Post by Mr Strech »

Ich würde gerne den Statistik-Block in der Mitte anzeigen lassen wollen und dachte mir, ich baue einfach den für die Seite um. Ganz so einfach ist es allerdings anscheinend nicht. :D

Ich habe mir die Dateien portal_statistics.php und statistics_side.html angeschaut und versucht, nach den Anweisungen in der Knowledge Base zu ändern. Das Problem ist nicht, dass es nicht richtig angezeigt wird, sondern dass ich das Modul im ACP nicht anwählen kann. Ich lasse mir den Statistikblock bereits als Admin an der Seite anzeigen und vermute mal, das ich eine Variable übersehen habe zu ändern und daher das Portal glaubt, dass das (center)-Modul bereits angezeigt wird.

Ich habe zuerst versucht, die Dateien einfach so hochzuladen und auch als ZIP. Hat beides nicht funktioniert.

Ich hänge das ZIP mal an und vielleicht würde jemand mal drüber schauen. Es würde mir als Grundlage dienen, für den alightner Calendar-Mod ebenfalls Blöcke fürs Portal zu erstellen. Aber eins nach dem Anderen.

Danke schonmal.


Edit: Leider kann ich keine Dateien anhängen. Hier der Link http://www.mrstrech.com/statistic_center_block.zip
User avatar

Kirk
Dev
Posts: 1950
Joined: 27. July 2010 18:02
phpBB.de User: Kirk
Contact:

Re: Eigener Block: Statistik Center-Block

Post by Kirk »

Hallo
Probier das hier mal aus:

portal_statistics_center.php

Code: Select all

<?php
/**
*
* @package Board3 Portal v2 - Statistics Center
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
	exit;
}

/**
* @package Portal Statistics Center
*/
class portal_statistics_center_module
{
	/**
	* Allowed columns: Just sum up your options (Exp: left + right = 10)
	* top		1
	* left		2
	* center	4
	* right		8
	* bottom	16
	*/
	public $columns = 21;

	/**
	* Default modulename
	*/
	public $name = 'PORTAL_STATISTICS_CENTER';

	/**
	* Default module-image:
	* file must be in "{T_THEME_PATH}/images/portal/"
	*/
	public $image_src = 'portal_statistics.png';

	/**
	* module-language file
	* file must be in "language/{$user->lang}/mods/portal/"
	*/
	public $language = 'portal_statistics_module';
	
	/**
	* custom acp template
	* file must be in "adm/style/portal/"
	*/
	public $custom_acp_tpl = '';

	public function get_template_center($module_id)
	{
		global $config, $template, $user;

		// Set some stats, get posts count from forums data if we... hum... retrieve all forums data
		$total_posts		= $config['num_posts'];
		$total_topics		= $config['num_topics'];
		$total_users		= $config['num_users'];
		$total_files 		= $config['num_files'];

		$l_total_user_s 	= ($total_users == 0) ? 'TOTAL_USERS_ZERO' : 'TOTAL_USERS_OTHER';
		$l_total_post_s 	= ($total_posts == 0) ? 'TOTAL_POSTS_ZERO' : 'TOTAL_POSTS_OTHER';
		$l_total_topic_s	= ($total_topics == 0) ? 'TOTAL_TOPICS_ZERO' : 'TOTAL_TOPICS_OTHER';

		// avarage stat
		$board_days = (time() - $config['board_startdate']) / 86400;

		$topics_per_day		= ($total_topics) ? round($total_topics / $board_days, 0) : 0;
		$posts_per_day		= ($total_posts) ? round($total_posts / $board_days, 0) : 0;
		$users_per_day		= round($total_users / $board_days, 0);
		$topics_per_user	= ($total_topics) ? round($total_topics / $total_users, 0) : 0;
		$posts_per_user		= ($total_posts) ? round($total_posts / $total_users, 0) : 0;
		$posts_per_topic	= ($total_topics) ? round($total_posts / $total_topics, 0) : 0;

		if ($topics_per_day > $total_topics)
		{
			$topics_per_day = $total_topics;
		}

		if ($posts_per_day > $total_posts)
		{
			$posts_per_day = $total_posts;
		}

		if ($users_per_day > $total_users)
		{
			$users_per_day = $total_users;
		}

		if ($topics_per_user > $total_topics)
		{
			$topics_per_user = $total_topics;
		}

		if ($posts_per_user > $total_posts)
		{
			$posts_per_user = $total_posts;
		}

		if ($posts_per_topic > $total_posts)
		{
			$posts_per_topic = $total_posts;
		}

		$l_topics_per_day_s = ($total_topics == 0) ? 'TOPICS_PER_DAY_ZERO' : 'TOPICS_PER_DAY_OTHER';
		$l_posts_per_day_s = ($total_posts == 0) ? 'POSTS_PER_DAY_ZERO' : 'POSTS_PER_DAY_OTHER';
		$l_users_per_day_s = ($total_users == 0) ? 'USERS_PER_DAY_ZERO' : 'USERS_PER_DAY_OTHER';
		$l_topics_per_user_s = ($total_topics == 0) ? 'TOPICS_PER_USER_ZERO' : 'TOPICS_PER_USER_OTHER';
		$l_posts_per_user_s = ($total_posts == 0) ? 'POSTS_PER_USER_ZERO' : 'POSTS_PER_USER_OTHER';
		$l_posts_per_topic_s = ($total_posts == 0) ? 'POSTS_PER_TOPIC_ZERO' : 'POSTS_PER_TOPIC_OTHER';

		$topics_count = $this->get_topics_count();


		// Assign specific vars
		$template->assign_vars(array(
			'B3_TOTAL_POSTS'				=> sprintf($user->lang[$l_total_post_s], $total_posts),
			'B3_TOTAL_TOPICS'				=> sprintf($user->lang[$l_total_topic_s], $total_topics),
			'B3_TOTAL_USERS'				=> sprintf($user->lang[$l_total_user_s], $total_users),
			'B3_NEWEST_USER'				=> sprintf($user->lang['NEWEST_USER'], get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),
			'B3_ANNOUNCE_COUNT'				=> $topics_count[POST_ANNOUNCE],
			'B3_STICKY_COUNT'				=> $topics_count[POST_STICKY],
			'B3_TOTAL_ATTACH'				=> ($config['allow_attachments']) ? $total_files : 0,

			// average stat
			'B3_TOPICS_PER_DAY'		=> sprintf($user->lang[$l_topics_per_day_s], $topics_per_day),
			'B3_POSTS_PER_DAY'		=> sprintf($user->lang[$l_posts_per_day_s], $posts_per_day),
			'B3_USERS_PER_DAY'		=> sprintf($user->lang[$l_users_per_day_s], $users_per_day),
			'B3_TOPICS_PER_USER'	=> sprintf($user->lang[$l_topics_per_user_s], $topics_per_user),
			'B3_POSTS_PER_USER'		=> sprintf($user->lang[$l_posts_per_user_s], $posts_per_user),
			'B3_POSTS_PER_TOPIC'	=> sprintf($user->lang[$l_posts_per_topic_s], $posts_per_topic),
		));
		return 'statistics_center.html';
	}

	public function get_template_acp($module_id)
	{
		return array(
			'title'	=> 'PORTAL_STATISTICS_CENTER',
			'vars'	=> array(),
		);
	}

	/**
	* API functions
	*/
	public function install($module_id)
	{
		return true;
	}

	public function uninstall($module_id)
	{
		return true;
	}
	
	// Better function with only one query
	public function get_topics_count()
	{
		global $db, $user;
		
		$return_ary = array(
			POST_ANNOUNCE => 0,
			POST_STICKY => 0,
		);
		
		$sql_in = array(
			POST_ANNOUNCE,
			POST_STICKY,
		);
		
		$sql = 'SELECT DISTINCT(topic_id) AS topic_id, topic_type AS type
					FROM ' . TOPICS_TABLE . '
					WHERE ' . $db->sql_in_set('topic_type', $sql_in, false);
		$result = $db->sql_query($sql);
		while ($row = $db->sql_fetchrow($result))
		{
			switch($row['type'])
			{
				case POST_ANNOUNCE:
					++$return_ary[POST_ANNOUNCE];
				break;
				
				case POST_STICKY:
					++$return_ary[POST_STICKY];
				break;
			}
		}
		$db->sql_freeresult($result);
		
		return $return_ary;
	}
}
In der portal_statistics_module.php must du noch folgendes ergänzen
Suche nach:

Code: Select all

$lang = array_merge($lang, array(
Füge danach in einer neuen Zeile das hier ein:

Code: Select all

'PORTAL_STATISTICS_CENTER'             =>'Statistik',
Deine html Datei hatte auch nicht ganz gepasst:
statistics_center.html

Code: Select all

{$C_BLOCK_H_L}{$TITLE}{$C_BLOCK_H_R}
	<ul class="topiclist bg1">
		<li><dl>
			<dd style="border-left:0px">
	<p style="margin: 0 5px 0 5px;">
	{START_DATE}</p>
			</dd>
		</dl></li>
	</ul>
{$C_BLOCK_F_L}{$C_BLOCK_F_R}
So funktioniert es. :)

Edit:
Hatte einen Fehler bei der language Datei drin.
Last edited by Kirk on 23. December 2011 19:01, edited 1 time in total.
Gruß Udo

Shorty1968
Portal Enthusiast
Posts: 149
Joined: 8. September 2011 01:16

Re: Eigener Block: Statistik Center-Block

Post by Shorty1968 »

Hallo Kirk
Ich würde meine Statistik Box auch gerne in die Mitte setzen und wollte deinen anleitung eben umsetzen,dabei ist mir aber aufgefallen das die Datein die du angibst wie z.b. portal_statistics_center.php oder portal_statistics_center_module.php es nicht gibt,ich vermute mal das man die selber neu erstellen muss oder?
User avatar

Kirk
Dev
Posts: 1950
Joined: 27. July 2010 18:02
phpBB.de User: Kirk
Contact:

Re: Eigener Block: Statistik Center-Block

Post by Kirk »

Hi Shorty

Ja diese Dateien must du erstellen (außer der portal_statistics_center_module.php die benötigt man nicht.) aber es gibt noch eine andere Lösung anstatt eine neue
portal_statistics_center.php Datei zu erstellen kann auch die portal_statistics.php erweitern
so das man den Block Statistik in die Mitte verschieben kann.

Suche in der portal_statistics.php nach:

Code: Select all

	/**
	* Allowed columns: Just sum up your options (Exp: left + right = 10)
	* top		1
	* left		2
	* center	4
	* right		8
	* bottom	16
	*/
	public $columns = 10;


Ersetze diese durch das hier:

Code: Select all

	/**
	* Allowed columns: Just sum up your options (Exp: left + right = 10)
	* top		1
	* left		2
	* center	4
	* right		8
	* bottom	16
	*/
	public $columns = 31;
Suche dann nach:

Code: Select all

public $custom_acp_tpl = '';
Füge danach das hier ein:

Code: Select all

	public function get_template_center($module_id)
	{
		global $config, $template, $user;

		// Set some stats, get posts count from forums data if we... hum... retrieve all forums data
		$total_posts		= $config['num_posts'];
		$total_topics		= $config['num_topics'];
		$total_users		= $config['num_users'];
		$total_files 		= $config['num_files'];

		$l_total_user_s 	= ($total_users == 0) ? 'TOTAL_USERS_ZERO' : 'TOTAL_USERS_OTHER';
		$l_total_post_s 	= ($total_posts == 0) ? 'TOTAL_POSTS_ZERO' : 'TOTAL_POSTS_OTHER';
		$l_total_topic_s	= ($total_topics == 0) ? 'TOTAL_TOPICS_ZERO' : 'TOTAL_TOPICS_OTHER';

		// avarage stat
		$board_days = (time() - $config['board_startdate']) / 86400;

		$topics_per_day		= ($total_topics) ? round($total_topics / $board_days, 0) : 0;
		$posts_per_day		= ($total_posts) ? round($total_posts / $board_days, 0) : 0;
		$users_per_day		= round($total_users / $board_days, 0);
		$topics_per_user	= ($total_topics) ? round($total_topics / $total_users, 0) : 0;
		$posts_per_user		= ($total_posts) ? round($total_posts / $total_users, 0) : 0;
		$posts_per_topic	= ($total_topics) ? round($total_posts / $total_topics, 0) : 0;

		if ($topics_per_day > $total_topics)
		{
			$topics_per_day = $total_topics;
		}

		if ($posts_per_day > $total_posts)
		{
			$posts_per_day = $total_posts;
		}

		if ($users_per_day > $total_users)
		{
			$users_per_day = $total_users;
		}

		if ($topics_per_user > $total_topics)
		{
			$topics_per_user = $total_topics;
		}

		if ($posts_per_user > $total_posts)
		{
			$posts_per_user = $total_posts;
		}

		if ($posts_per_topic > $total_posts)
		{
			$posts_per_topic = $total_posts;
		}

		$l_topics_per_day_s = ($total_topics == 0) ? 'TOPICS_PER_DAY_ZERO' : 'TOPICS_PER_DAY_OTHER';
		$l_posts_per_day_s = ($total_posts == 0) ? 'POSTS_PER_DAY_ZERO' : 'POSTS_PER_DAY_OTHER';
		$l_users_per_day_s = ($total_users == 0) ? 'USERS_PER_DAY_ZERO' : 'USERS_PER_DAY_OTHER';
		$l_topics_per_user_s = ($total_topics == 0) ? 'TOPICS_PER_USER_ZERO' : 'TOPICS_PER_USER_OTHER';
		$l_posts_per_user_s = ($total_posts == 0) ? 'POSTS_PER_USER_ZERO' : 'POSTS_PER_USER_OTHER';
		$l_posts_per_topic_s = ($total_posts == 0) ? 'POSTS_PER_TOPIC_ZERO' : 'POSTS_PER_TOPIC_OTHER';

		$topics_count = $this->get_topics_count();


		// Assign specific vars
		$template->assign_vars(array(
			'B3_TOTAL_POSTS'				=> sprintf($user->lang[$l_total_post_s], $total_posts),
			'B3_TOTAL_TOPICS'				=> sprintf($user->lang[$l_total_topic_s], $total_topics),
			'B3_TOTAL_USERS'				=> sprintf($user->lang[$l_total_user_s], $total_users),
			'B3_NEWEST_USER'				=> sprintf($user->lang['NEWEST_USER'], get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),
			'B3_ANNOUNCE_COUNT'				=> $topics_count[POST_ANNOUNCE],
			'B3_STICKY_COUNT'				=> $topics_count[POST_STICKY],
			'B3_TOTAL_ATTACH'				=> ($config['allow_attachments']) ? $total_files : 0,

			// average stat
			'B3_TOPICS_PER_DAY'		=> sprintf($user->lang[$l_topics_per_day_s], $topics_per_day),
			'B3_POSTS_PER_DAY'		=> sprintf($user->lang[$l_posts_per_day_s], $posts_per_day),
			'B3_USERS_PER_DAY'		=> sprintf($user->lang[$l_users_per_day_s], $users_per_day),
			'B3_TOPICS_PER_USER'	=> sprintf($user->lang[$l_topics_per_user_s], $topics_per_user),
			'B3_POSTS_PER_USER'		=> sprintf($user->lang[$l_posts_per_user_s], $posts_per_user),
			'B3_POSTS_PER_TOPIC'	=> sprintf($user->lang[$l_posts_per_topic_s], $posts_per_topic),
		));
		return 'statistics_center.html';
	}
Die html Datei benötigt man aber dennoch.
Gruß Udo

Shorty1968
Portal Enthusiast
Posts: 149
Joined: 8. September 2011 01:16

Re: Eigener Block: Statistik Center-Block

Post by Shorty1968 »

Hallo Kirk
Danke das ist besser und geht auch nur bei der statistics_center.html wurde mit deinem inhalt nichts angezeigt wenn ich das:

Code: Select all

{$LR_BLOCK_H_L}<!-- IF $S_BLOCK_ICON --><img src="{$IMAGE_SRC}" width="{$IMAGE_WIDTH}" height="{$IMAGE_HEIGHT}" alt="" />&nbsp;<!-- ENDIF -->{$TITLE}{$LR_BLOCK_H_R}
	<strong>{L_ST_TOP}</strong>
	{B3_TOTAL_POSTS}
	{B3_TOTAL_TOPICS}
	{L_ST_TOP_ANNS} <strong>{B3_ANNOUNCE_COUNT}</strong>
	{L_ST_TOP_STICKYS} <strong>{B3_STICKY_COUNT}</strong>
	{L_ST_TOT_ATTACH} <strong>{B3_TOTAL_ATTACH}</strong>
		
	<hr class="dashed" />
	{B3_TOPICS_PER_DAY}
	{B3_POSTS_PER_DAY}
	{B3_USERS_PER_DAY}
	{B3_TOPICS_PER_USER}
	{B3_POSTS_PER_USER}
	{B3_POSTS_PER_TOPIC}
	<hr class="dashed" />
	
	{B3_TOTAL_USERS}
	{B3_NEWEST_USER}
{$LR_BLOCK_F_L}{$LR_BLOCK_F_R}
nehme wird die Stat in der mitte angezeigt.
User avatar

Kirk
Dev
Posts: 1950
Joined: 27. July 2010 18:02
phpBB.de User: Kirk
Contact:

Re: Eigener Block: Statistik Center-Block

Post by Kirk »

Bei mir geht beides. ;)
Gruß Udo

Shorty1968
Portal Enthusiast
Posts: 149
Joined: 8. September 2011 01:16

Re: Eigener Block: Statistik Center-Block

Post by Shorty1968 »

Eine Frage hätte ich da noch wie müsste das template für subsilver2 aussehen der inhalt?
User avatar

Kirk
Dev
Posts: 1950
Joined: 27. July 2010 18:02
phpBB.de User: Kirk
Contact:

Re: Eigener Block: Statistik Center-Block

Post by Kirk »

Probier es mal damit:

Code: Select all

{$C_BLOCK_H_L}{$TITLE}{$C_BLOCK_H_R}
<table class="tablebg" cellspacing="1" width="100%">
<tr>
   <td class="row1" width="100%"><span class="genmed">	<strong>{L_ST_TOP}:</strong><br /><br />
	{B3_TOTAL_POSTS} | {B3_TOTAL_TOPICS} | {L_ST_TOP_ANNS} <strong>{B3_ANNOUNCE_COUNT}</strong><br />
	{L_ST_TOP_STICKYS} <strong>{B3_STICKY_COUNT}</strong> | {L_ST_TOT_ATTACH} <strong>{B3_TOTAL_ATTACH}</strong><br />
		
	<hr class="dashed" />
	{B3_TOPICS_PER_DAY} | {B3_POSTS_PER_DAY} | {B3_USERS_PER_DAY}<br />
	{B3_TOPICS_PER_USER} | {B3_POSTS_PER_USER} | {B3_POSTS_PER_TOPIC}<br />
	<hr class="dashed" />
	
	{B3_TOTAL_USERS} | {B3_NEWEST_USER}</span></td>
</tr>
</table>
{$C_BLOCK_F_L}{$C_BLOCK_F_R}
Gruß Udo

Shorty1968
Portal Enthusiast
Posts: 149
Joined: 8. September 2011 01:16

Re: Eigener Block: Statistik Center-Block

Post by Shorty1968 »

Hallo Kirk
Danke perfekt nun nur noch eine kleinigkeit wie bekomme ich einen abstand zu den anderen Boxen hin wie bei den anderen auch?
User avatar

Kirk
Dev
Posts: 1950
Joined: 27. July 2010 18:02
phpBB.de User: Kirk
Contact:

Re: Eigener Block: Statistik Center-Block

Post by Kirk »

Also in mein Testboard hab ich einen Abstand zu den anderen Boxen drin.
Ein Link oder Screenshot wäre hilfreich, liegt vermutlich an der _block_config.html.
Gruß Udo

Shorty1968
Portal Enthusiast
Posts: 149
Joined: 8. September 2011 01:16

Re: Eigener Block: Statistik Center-Block

Post by Shorty1968 »

Hallo Kirk
Hier bitte ein Link http://www.computer-base.net/portal.php es scheint aber nur bei den subsilver2 Basierenden styles zu sein wie z.b. swirly_orange und swirly_blue.

Topic author
Mr Strech
Active Member
Posts: 29
Joined: 29. December 2009 16:25
phpBB.de User: Mr Strech

Re: Eigener Block: Statistik Center-Block

Post by Mr Strech »

Super, danke, werde ich dann mal gleich ausprobieren.

Topic author
Mr Strech
Active Member
Posts: 29
Joined: 29. December 2009 16:25
phpBB.de User: Mr Strech

Re: Eigener Block: Statistik Center-Block

Post by Mr Strech »

Danke Kirk, für deine Hilfe. :)

Ich hab das ZIP mal aktualisiert und nochmal hochgeladen: http://www.mrstrech.com/statistic_center_block.zip
Kirk wrote:
In der portal_statistics_module.php must du noch folgendes ergänzen
Suche nach:

Code: Select all

$lang = array_merge($lang, array(
Füge danach in einer neuen Zeile das hier ein:

Code: Select all

'PORTAL_STATISTICS_CENTER'             =>'Statistik',
Irgendwie ist es bei der neuen Portalversion deutlich schwieriger, Änderungen zu machen. Hat schon jemand versucht, an die "gesamten Bilder" von der Galerie von Nickvergessen ranzukommen? Mit einfügen von "<!-- IF TOTAL_IMAGES --> &bull; {TOTAL_IMAGES}<!-- ENDIF -->" bzw. "{TOTAL_IMAGES}" ist es leider nicht getan.
Post Reply

Return to “Modification Requests”