SimplePortal

Customization => Custom Coding => Topic started by: Renegd98 on June 13, 2010, 11:00:26 AM

Title: Need help on simple code I call Forums Roundup
Post by: Renegd98 on June 13, 2010, 11:00:26 AM
I made the following page with the below code:

Code: [Select]
global $txt

$txt['recent_topics'] = 'Recent Topics';
$txt['recent_posts'] = 'Recent Posts';

$buttons = array(
   'recent_topics' => array(
      'text' => 'recent_topics',
      'image' => '',
      'lang' => true,
      'url' => '#recent_topics" id="b_rt" onclick="change_display(\'rp\'); return false;',
      'active' => true,
   ),
   'recent_posts' => array(
      'text' => 'recent_posts',
      'image' => '',
      'lang' => true,
      'url' => '#recent_posts" id="b_rp" onclick="change_display(\'rt\'); return false;',
   ),
);

echo '
<div style="overflow: auto;">
   ', template_button_strip($buttons), '
</div>
<div id="recent_topics">
   ', sp_recent(array('type' => 1, 'display' => 1, 'limit' => 10), 0), '
</div>
<div id="recent_posts" style="display: none;">
   ', sp_recent(array('display' => 1, 'limit' => 10), 0), '
</div>
</div>
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
   function change_display(block)
   {
      var current = block == \'rt\' ? 1 : 0;

      document.getElementById(\'recent_topics\').style.display = current ? \'none\' : \'\';
      document.getElementById(\'recent_posts\').style.display = current ? \'\' : \'none\';
      document.getElementById(\'b_rt\').className = current ? \'button_strip_recent_topics\' : \'button_strip_recent_topics active\';
      document.getElementById(\'b_rp\').className = current ? \'button_strip_recent_posts active\' : \'button_strip_recent_posts\';

   }
// ]]></script>';
echo '<table border="2" width="100%" cellpadding="2" cellspacing="2" valign="top"> ';
echo '<tr>';

echo '<td width="50%" valign="top">';
echo '<u>Latest Members</u>';
echo'<hr>';
sp_latestMember(array('display' => 1, 'limit' => 10), 0);
echo'</td>';

echo'<td>';
echo '<u>Who is Online</u>';
echo'<hr>';
sp_whosOnline(array(), $id);
echo '</td>';
echo'</tr>';

echo'<tr>';

echo'<td>';
echo '<u>Board Stats</u>';
echo'<hr>';
sp_boardStats(array('averages' => 1), $id);
echo'</td>';
echo'<td>&nbsp;</td>';
echo'</tr>';
echo'<tr>';
echo'<td>';
echo'<u>Top Poster</u>';
echo'<hr>';
sp_topPoster(array('display' => 1, 'limit' => 10), 0);
echo'</td>';
echo'<td valign="top">';
echo'<u>Top Stats Member</u>';
echo'<hr>';
sp_topStatsMember(array('display' => 1, 'limit' => 10), 0);
echo'</td>';
echo'</tr>';
echo'<tr>';
echo'<td>';
echo'<u>Top Topics</u>';
echo'<hr>';
sp_topTopics(array('display' => 1, 'limit' => 10), 0);
echo'</td>';
echo'<td>';
echo'<u>Top Boards</u>';
echo'<hr>';
sp_topBoards(array('display' => 1, 'limit' => 10), 0);
echo'</td>';
echo'</tr>';

echo'<hr>';
echo '</table>';


And I get the 2 errors in the log file about the $id variable in the who's online and boards stats... How can I fix these errors?

 
Title: Re: Need help on simple code I call Forums Roundup
Post by: Nathaniel on June 13, 2010, 09:31:35 PM
Quite a nice looking page, try the code below:
Code: [Select]
global $txt;

$txt['recent_topics'] = 'Recent Topics';
$txt['recent_posts'] = 'Recent Posts';

$buttons = array(
   'recent_topics' => array(
      'text' => 'recent_topics',
      'image' => '',
      'lang' => true,
      'url' => '#recent_topics" id="b_rt" onclick="change_display(\'rp\'); return false;',
      'active' => true,
   ),
   'recent_posts' => array(
      'text' => 'recent_posts',
      'image' => '',
      'lang' => true,
      'url' => '#recent_posts" id="b_rp" onclick="change_display(\'rt\'); return false;',
   ),
);

echo '
<div style="overflow: auto;">
   ', template_button_strip($buttons), '
</div>
<div id="recent_topics">
   ', sp_recent(array('type' => 1, 'display' => 1, 'limit' => 10), 0), '
</div>
<div id="recent_posts" style="display: none;">
   ', sp_recent(array('display' => 1, 'limit' => 10), 0), '
</div>
</div>
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
   function change_display(block)
   {
      var current = block == \'rt\' ? 1 : 0;

      document.getElementById(\'recent_topics\').style.display = current ? \'none\' : \'\';
      document.getElementById(\'recent_posts\').style.display = current ? \'\' : \'none\';
      document.getElementById(\'b_rt\').className = current ? \'button_strip_recent_topics\' : \'button_strip_recent_topics active\';
      document.getElementById(\'b_rp\').className = current ? \'button_strip_recent_posts active\' : \'button_strip_recent_posts\';

   }
// ]]></script>';
echo '<table border="2" width="100%" cellpadding="2" cellspacing="2" valign="top"> ';
echo '<tr>';

echo '<td width="50%" valign="top">';
echo '<u>Latest Members</u>';
echo'<hr>';
sp_latestMember(array('display' => 1, 'limit' => 10), 0);
echo'</td>';

echo'<td>';
echo '<u>Who is Online</u>';
echo'<hr>';
sp_whosOnline(array(), 0);
echo '</td>';
echo'</tr>';

echo'<tr>';

echo'<td>';
echo '<u>Board Stats</u>';
echo'<hr>';
sp_boardStats(array('averages' => 1), 0);
echo'</td>';
echo'<td>&nbsp;</td>';
echo'</tr>';
echo'<tr>';
echo'<td>';
echo'<u>Top Poster</u>';
echo'<hr>';
sp_topPoster(array('display' => 1, 'limit' => 10), 0);
echo'</td>';
echo'<td valign="top">';
echo'<u>Top Stats Member</u>';
echo'<hr>';
sp_topStatsMember(array('display' => 1, 'limit' => 10), 0);
echo'</td>';
echo'</tr>';
echo'<tr>';
echo'<td>';
echo'<u>Top Topics</u>';
echo'<hr>';
sp_topTopics(array('display' => 1, 'limit' => 10), 0);
echo'</td>';
echo'<td>';
echo'<u>Top Boards</u>';
echo'<hr>';
sp_topBoards(array('display' => 1, 'limit' => 10), 0);
echo'</td>';
echo'</tr>';

echo'<hr>';
echo '</table>';

 

Changes:
- Added a semicolon to the end of the first line.
- Replaced $id with '0' in two places.
Title: Re: Need help on simple code I call Forums Roundup
Post by: Renegd98 on June 13, 2010, 10:02:17 PM
Thanks... errors fixed... appreciate all the help.
SimplePortal 2.3.8 © 2008-2024, SimplePortal