News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Stats - using one block in a single page

Started by FragaCampos, September 07, 2016, 01:37:00 AM

Previous topic - Next topic

FragaCampos

Hi there.

I would like to use one of the Stats' page blocks in a static html page, which I could access via a main menu link.
The thing is I don't have a clue on how to do this...  :P

How can I use a piece of PHP code from Stats.php (say Topic poster top 10) in a html file?

Pipke

you can take a look at http://www.simplemachines.org/community/ssi_examples.php and maybe learn from it?

Top Topics
Shows top topics by the number of replies or views.

Code (show by number of views)

Code:
<?php ssi_topTopicsViews(); ?>
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

FragaCampos

That's a possibility, but I woudl prefer to use the block as it is, like a copy of what's in the stats page, but more accessible and trimmed.

Pipke

maybe this is where you looking for in php:

note for this line -> require(dirname(__FILE__) . '/forum/SSI.php'); (set this to your own path to the SSI.php file!)



<?php
// Include the SSI file.
require(dirname(__FILE__) . '/forum/SSI.php');

global 
$context$settings$txt$scripturl$sourcedir;

require_once(
$sourcedir '/Stats.php');
DisplayStats();

echo 
'
    <html><head>
<title>'
$context['page_title'], '</title>
<link rel="stylesheet" type="text/css" href="'
$settings['theme_url'], '/css/index.css" />
</head>
<body style="background: none;">
<div id="statistics" class="main_section">
<div class="cat_bar">
<h3 class="catbg">'
$context['page_title'], '</h3>
</div>
<div class="title_bar">
<h4 class="titlebg">
<span class="ie6_header floatleft">
<img src="'
$settings['images_url'], '/stats_info.gif" class="icon" alt="" /> '$txt['general_stats'], '
</span>
</h4>
</div>
<div class="flow_hidden">
<div id="top_topics_replies">
<div class="title_bar">
<h4 class="titlebg">
<span class="ie6_header floatleft">
<img src="'
$settings['images_url'], '/stats_replies.gif" class="icon" alt="" /> '$txt['top_topics_replies'], '
</span>
</h4>
</div>
<div class="windowbg2">
<span class="topslice"><span></span></span>
<div class="content">
<dl class="stats">'
;

foreach ($context['top_topics_replies'] as $topic)
{
echo '
<dt>
'
$topic['link'], '
</dt>
<dd class="statsbar">'
;
if (!empty($topic['post_percent']))
echo '
<div class="bar" style="width: '
$topic['post_percent'] + 4'px;">
<div style="width: '
$topic['post_percent'], 'px;"></div>
</div>'
;

echo '
<span class="righttext">' 
$topic['num_replies'] . '</span>
</dd>'
;
}
echo '
</dl>
<div class="clear"></div>
</div>
<span class="botslice"><span></span></span>
</div>
</div>

<div id="top_topics_views">
<div class="title_bar">
<h4 class="titlebg">
<span class="ie6_header floatleft">
<img src="'
$settings['images_url'], '/stats_views.gif" class="icon" alt="" /> '$txt['top_topics_views'], '
</span>
</h4>
</div>
<div class="windowbg2">
<span class="topslice"><span></span></span>
<div class="content">
<dl class="stats">'
;

foreach ($context['top_topics_views'] as $topic)
{
echo '
<dt>'
$topic['link'], '</dt>
<dd class="statsbar">'
;

if (!empty($topic['post_percent']))
echo '
<div class="bar" style="width: '
$topic['post_percent'] + 4'px;">
<div style="width: '
$topic['post_percent'], 'px;"></div>
</div>'
;

echo '
<span class="righttext">' 
$topic['num_views'] . '</span>
</dd>'
;
}

echo '
</dl>
<div class="clear"></div>
</div>
<span class="botslice"><span></span></span>
</div>
</div>
</div>
</div>
</body>
</html>'
;

?>

"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

FragaCampos


Advertisement: