TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

May 19, 2024, 12:03:20 AM

Login with username, password and session length
Members
  • Total Members: 3,886
  • Latest: Grendor
Stats
  • Total Posts: 195,189
  • Total Topics: 21,220
  • Online today: 70
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 72
  • Total: 72

Urgently require help with the tabbed block snippet

Started by agent47, March 07, 2011, 09:29:37 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

agent47

I tried asking this on SMF but no one seems to be responding.

If you look at my site which is http://www.superheroalliance.net | you'll notice a tabbed block that displays the 15 most recent topics.
Now I kinda need some help with a couple of things here.

1). Firstly, I would like add another column to the block that displays the time of the last post which will make the block look like as shown in the image below (Code provided below. Please state the line and where it should go.)



2). My second question is how do I make the recent topics title bar to look more like the one shown in the image above.

3). The next thing is heres the code to my block and I was wondering if someone can strip it down and remove unnecessary lines and simplify it so that I can share with the rest of the class.

<?php
// ===============================================================================================
// mouseoverTabContent.php
// 23rd September 2010
//
// Code is based on the work of StormLrd and modifications by dimdom.
// This file pulls together their work and has been assembled by Freddy888.
//
// This file is designed to pull data from an SMF forum and put it in a Tiny Portal tabbed block.
// This uses a  modified version of the 'Mouseover Tabs Menu' at 
// http://www.dynamicdrive.com/dynamicindex1/mouseovertabs.htm
//
// Functions are prefixed 'mot_' meaning 'mouse over tab'.
// Basically each function equals one tab contents in your Tiny Portal block code.
// The order in which the functions are called is the order the tabs will appear in.
// You can put whatever you like in these functions or add more,
// this method just makes it easier to move stuff around.
//
// The actual 'output' from this file occurs at the end of this file.
// You can skip down to the bottom to fine tune things...
//
// Functions in this version :
// mot_NewTopics
// mot_TPTools
// mot_NewArticles
// mot_NewFiles1
// mot_NewFiles2
// mot_Statistics
// mot_Member
// mot_Search
// ===============================================================================================



// ****************
// INITIALISATION..
// ****************

// In the block code you can set the categories for the 'New Articles' tab, so you don't have to edit this code.
// This should make it easier to work with this function.
if (isset($_GET['categories']))
// Were some categories sent ?
$categories explode("," $_GET['categories']);
else
// if not just do a guess...
$categories = array(1,2,3,4,5,6);

// The mouseover tabs JS code generates a $_GET we don't need at this point it seems.
// We need to empty the $_GET variable here otherwise SMF throws a 'Invalid request variable'.
// See circa line 99 in QueryString.php for more info. 888
$_GET = array();

// Going to need all the useful things in SSI.
require_once('../SSI.php');

// Initialise Tiny Portal.
TPortal_init();

// Work out where all the TP images are....
$tpimagesurl $boardurl '/Themes/default/images/tinyportal';
$tpimg['options'] = $tpimagesurl '/TPoptions.gif';
$tpimg['bullet4'] = '<img src="' $tpimagesurl '/TPgoto.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$tpimg['tpblue'] = $tpimagesurl '/TPblue.gif';
$tpimg['bullet1'] = '<img src="'$tpimagesurl '/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$tpimg['bullet2'] = '<img src="'$tpimagesurl '/TPdivider2.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$tpimg['bullet3'] = '<img src="' $tpimagesurl '/TPdivider3.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$tpimg['article'] = $tpimagesurl '/TParticle.gif';




// *************
// The Functions
// *************


// Grabs recent topics...
function mot_NewTopics()
{
global $scripturl$settings$context$txt;
echo 
' <div class="titlebg2">Recent Topics</div>';

   
$what ssi_recentTopics('15',NULL,'array');

echo '
<div class="tabsmenucontent" style="padding: 5px">
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
<tr class="catbg3">
<td valign="middle"></td>
</tr>'
;

foreach ($what as $topic)
{
echo '
<tr>
<td class="windowbg" valign="middle">'
$topic['link'];

// Is this topic new? (assuming they are logged in!)
if (!$topic['new'] && $context['user']['is_logged'])
echo '
<a href="'
$scripturl'?topic='$topic['topic'], '.from'$topic['time'], '#new"><img src="'$settings['images_url'], '/'$context['user']['language'], '/new.gif" alt="new" border="0" /></a>';

echo '
</td>
<td class="windowbg2" valign="middle">'
$topic['poster']['link'], '</td>
<td class="windowbg2">'
$board['last_post']['time'], '</td>
<td class="windowbg2" valign="middle">'
;

if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
echo '
<a href="'
$topic['href'], '"><img src="'$settings['images_url'], '/icons/last_post.gif" alt="Last Post" title="Last Post" border="0" style="float: right;" /></a>';
}

echo 
'
</td>
</tr>
</table>
</div>'
;
}

function 
mot_NewTopics1()
{
global $scripturl$settings$context$txt;

$what ssi_recentTopics('15', array(2,30,4,3,5,39,40,42,43,45,41,6,34,33,35,25,32,36,17,8,11,10,9,12,15,14,13,20,37,31,29,38,16,19,27,24),'array');

echo '
<div class="tabsmenucontent" style="padding: 5px">
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
<tr class="catbg3">
<td valign="middle"></td>
</tr>'
;

foreach ($what as $topic)
{
echo '
<tr>
<td class="windowbg" valign="middle">'
$topic['link'];

// Is this topic new? (assuming they are logged in!)
if (!$topic['new'] && $context['user']['is_logged'])
echo '
<a href="'
$scripturl'?topic='$topic['topic'], '.from'$topic['time'], '#new"><img src="'$settings['images_url'], '/'$context['user']['language'], '/new.gif" alt="new" border="0" /></a>';

echo '
</td>
<td class="windowbg2" valign="middle">'
$topic['poster']['link'], '</td>
<td class="windowbg2" valign="middle">'
;

if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
echo '
<a href="'
$topic['href'], '"><img src="'$settings['images_url'], '/icons/last_post.gif" alt="Last Post" title="Last Post" border="0" style="float: right;" /></a>';
}

echo 
'
</td>
</tr>
</table>
</div>'
;
}

function 
mot_NewTopics2()
{
global $scripturl$settings$context$txt;

$what ssi_recentTopics('15', array(2,30,4,3,5,40,42,43,45,41,6,34,33,35,25,32,36,17,8,11,10,9,12,15,14,13,20,37,31,29,38,16,19,27,24,28),'array');

echo '
<div class="tabsmenucontent" style="padding: 5px">
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
<tr class="catbg3">
<td valign="middle"></td>
</tr>'
;

foreach ($what as $topic)
{
echo '
<tr>
<td class="windowbg" valign="middle">'
$topic['link'];

// Is this topic new? (assuming they are logged in!)
if (!$topic['new'] && $context['user']['is_logged'])
echo '
<a href="'
$scripturl'?topic='$topic['topic'], '.from'$topic['time'], '#new"><img src="'$settings['images_url'], '/'$context['user']['language'], '/new.gif" alt="new" border="0" /></a>';

echo '
</td>
<td class="windowbg2" valign="middle">'
$topic['poster']['link'], '</td>
<td class="windowbg2" valign="middle">'
;

if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
echo '
<a href="'
$topic['href'], '"><img src="'$settings['images_url'], '/icons/last_post.gif" alt="Last Post" title="Last Post" border="0" style="float: right;" /></a>';
}

echo 
'
</td>
</tr>
</table>
</div>'
;
}

function 
mot_NewTopics3()
{
global $scripturl$settings$context$txt;

$what ssi_recentTopics('15', array(2,30,4,3,5,39,40,42,43,45,41,6,34,33,35,25,32,36,17,11,10,9,12,15,14,13,20,37,31,29,38,16,19,27,24,28),'array');

echo '
<div class="tabsmenucontent" style="padding: 5px">
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
<tr class="catbg3">
<td valign="middle"></td>
</tr>'
;

foreach ($what as $topic)
{
echo '
<tr>
<td class="windowbg" valign="middle">'
$topic['link'];

// Is this topic new? (assuming they are logged in!)
if (!$topic['new'] && $context['user']['is_logged'])
echo '
<a href="'
$scripturl'?topic='$topic['topic'], '.from'$topic['time'], '#new"><img src="'$settings['images_url'], '/'$context['user']['language'], '/new.gif" alt="new" border="0" /></a>';

echo '
</td>
<td class="windowbg2" valign="middle">'
$topic['poster']['link'], '</td>
<td class="windowbg2" valign="middle">'
;

if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
echo '
<a href="'
$topic['href'], '"><img src="'$settings['images_url'], '/icons/last_post.gif" alt="Last Post" title="Last Post" border="0" style="float: right;" /></a>';
}

echo 
'
</td>
</tr>
</table>
</div>'
;
}

function 
mot_NewTopics4()
{
global $scripturl$settings$context$txt;

$what ssi_recentTopics('15', array(2,30,4,3,5,39,40,42,43,45,41,6,34,33,35,25,32,36,17,8,10,9,12,15,14,13,20,37,31,29,38,16,19,27,24,28),'array');

echo '
<div class="tabsmenucontent" style="padding: 5px">
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
<tr class="catbg3">
<td valign="middle"></td>
</tr>'
;

foreach ($what as $topic)
{
echo '
<tr>
<td class="windowbg" valign="middle">'
$topic['link'];

// Is this topic new? (assuming they are logged in!)
if (!$topic['new'] && $context['user']['is_logged'])
echo '
<a href="'
$scripturl'?topic='$topic['topic'], '.from'$topic['time'], '#new"><img src="'$settings['images_url'], '/'$context['user']['language'], '/new.gif" alt="new" border="0" /></a>';

echo '
</td>
<td class="windowbg2" valign="middle">'
$topic['poster']['link'], '</td>
<td class="windowbg2" valign="middle">'
;

if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
echo '
<a href="'
$topic['href'], '"><img src="'$settings['images_url'], '/icons/last_post.gif" alt="Last Post" title="Last Post" border="0" style="float: right;" /></a>';
}

echo 
'
</td>
</tr>
</table>
</div>'
;
}

function 
mot_NewTopics5()
{
global $scripturl$settings$context$txt;

$what ssi_recentTopics('15', array(2,30,4,3,5,39,40,42,43,45,41,6,34,33,35,25,32,36,17,8,11,10,9,15,14,13,20,37,31,29,38,16,19,27,24,28),'array');

echo '
<div class="tabsmenucontent" style="padding: 5px">
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
<tr class="catbg3">
<td valign="middle"></td>
</tr>'
;

foreach ($what as $topic)
{
echo '
<tr>
<td class="windowbg" valign="middle">'
$topic['link'];

// Is this topic new? (assuming they are logged in!)
if (!$topic['new'] && $context['user']['is_logged'])
echo '
<a href="'
$scripturl'?topic='$topic['topic'], '.from'$topic['time'], '#new"><img src="'$settings['images_url'], '/'$context['user']['language'], '/new.gif" alt="new" border="0" /></a>';

echo '
</td>
<td class="windowbg2" valign="middle">'
$topic['poster']['link'], '</td>
<td class="windowbg2" valign="middle">'
;

if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
echo '
<a href="'
$topic['href'], '"><img src="'$settings['images_url'], '/icons/last_post.gif" alt="Last Post" title="Last Post" border="0" style="float: right;" /></a>';
}

echo 
'
</td>
</tr>
</table>
</div>'
;
}

function 
mot_NewTopics6()
{
global $scripturl$settings$context$txt;

$what ssi_recentTopics('15', array(2,30,4,3,5,39,40,42,43,45,41,6,34,33,35,25,32,36,17,8,11,10,9,12,14,13,20,37,31,29,38,16,19,27,24,28),'array');

echo '
<div class="tabsmenucontent" style="padding: 5px">
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
<tr class="catbg3">
<td valign="middle"></td>
</tr>'
;

foreach ($what as $topic)
{
echo '
<tr>
<td class="windowbg" valign="middle">'
$topic['link'];

// Is this topic new? (assuming they are logged in!)
if (!$topic['new'] && $context['user']['is_logged'])
echo '
<a href="'
$scripturl'?topic='$topic['topic'], '.from'$topic['time'], '#new"><img src="'$settings['images_url'], '/'$context['user']['language'], '/new.gif" alt="new" border="0" /></a>';

echo '
</td>
<td class="windowbg2" valign="middle">'
$topic['poster']['link'], '</td>
<td class="windowbg2" valign="middle">'
;

if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
echo '
<a href="'
$topic['href'], '"><img src="'$settings['images_url'], '/icons/last_post.gif" alt="Last Post" title="Last Post" border="0" style="float: right;" /></a>';
}

echo 
'
</td>
</tr>
</table>
</div>'
;
}

/*
// An example function...don't forget to call it in the config at the bottom!

function mot_myFunction()
{
global $what $ever $you $need $here;

echo '
<div class="tabsmenucontent" style="padding: 5px">'

// All your code goes here...

echo '
</div>';
}
*/




// *************************************
// And finally output & configuration...
// *************************************

echo '
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>'
;

// Call each function in the order you want them to appear in the tabs.
// This should correspond with what you have in your TP block code too.
// So make sure your tabs are in the same order as these functions.

// mot_NewArticles configuration :
// $mode :
//  1= order by date
// 2= order by comments
// 3= order by views
// 4= order by rating
// 6= order randomly
//
// $limit = number of items
// $cats = categories to include [changed to use the passed GET variable from the TP block 888]
//  Others are obvious..

// All boards
mot_NewTopics();
// Comics Discussion
mot_NewTopics1();
// TV, Movies & Music
mot_NewTopics2();
        
// DC Discussion
        
mot_NewTopics3();
        
// DC Movies
        
mot_NewTopics4();
        
// DC Movies
        
mot_NewTopics5();
        
// DC Movies
        
mot_NewTopics6();
?>


4). The other thing is also that as soon as the site loads it doesn't display content from the "ALL" tab unless someone rolls over it even though I have asked it to by default show the content from the first tab.

I know it's alotta questions but you have no idea how excited I am as I was looking for a snippet like this for a really long time so I want it to look perfect.

agent47

Just thought I'd bump this thread to bring it forward to the recent topics page.