TinyPortal

Development => Support => Topic started by: kmccann on June 05, 2007, 07:23:47 PM

Title: Integration and blocks
Post by: kmccann on June 05, 2007, 07:23:47 PM
Hi,

I am working on integrating SMF, TP and my own custom app that handles pool league stats. See the basic idea here:

http://smfsite.in2pool.com/stats.php?op=teamstandings&did=12

In the above page, I'm calling SSI.php and building the tab links in the header. Works fine. On the left I have a hard-coded block of items, and to the right I display my stats content. The left block is controlled by a header file in my custom app, and, as mentioned, the content is hard-coded.

Question:  after having included SSI.php, is there an easy way to "call" the real left blocks - ie, the ones that would normally appear on the homepage? Something like:

get_left_blocks();  or
get_left_panel();

Maybe someone has had a need to do this kind of thing before and could offer suggestions.

Thanks,
Kevin







Title: Re: Integration and blocks
Post by: Zetan on June 05, 2007, 07:54:23 PM
Each individual block has it's own ID Block number.

For example, the User block here at TP:
<a href="http://www.tinyportal.net/index.php?action=profile;u=11664">User</a>
</h3>
<div class="windowbg tp_leftblock_body" style="padding:4px; " id="block1">






For whole left or right panels I guess you could use the Upshrink functions that collapse/hide and expand/show the left and right panels.

an example from TP source.
<a href="#" onclick="shrinkHeader(!current_header); return false;"><img id="upshrink" src="http://www.tinyportal.net/Themes/newdef/images/upshrink.gif" alt="*" title="Shrink or expand the header." align="bottom" style="margin: 0 1ex;" /></a> L<a href="javascript:void(0);" onclick="shrinkHeaderLeftbar(!current_leftbar); return false;"><img id="upshrinkLeftbar" src="http://www.tinyportal.net/Themes/newdef/images/upshrink.gif" alt="*" title="Shrink or expand the header." style="margin: 0 1ex;" border="0" /></a><img id="upshrinkTempLeftbar" src="http://www.tinyportal.net/Themes/newdef/images/blank.gif" alt="" style="margin-right: 0ex;" />


I'm not the best coder here to be honest.. just some thoughts.
Title: Re: Integration and blocks
Post by: kmccann on June 05, 2007, 08:08:23 PM
I thought I was on to something when I saw code in index.template.php that starts with:

// TinyPortal integrated bars
          if($context['TPortal']['leftbar'])
...

The following routine is called:

TPortal_sidebar('left');

However, it seems like  $context['TPortal']['leftbar']  is  untrue. Also tried just  $context['TPortal']  and it is also untrue.

So .... I wonder how I initiate the Tportal stuff from an external script.

- Kevin
Title: Re: Integration and blocks
Post by: kmccann on June 05, 2007, 08:35:15 PM
OK, looks like I need to load:

$smfdir/Sources/TPortal.php

(and I would love to have access to the TPortal functions from within my custom app script)

However, when I include the file in my script (after including SSI.php), I get:

Fatal error: Cannot redeclare tportal_init() (previously declared in /path/to/mysite/Sources/TPortal.php:20) in /path/to/mysite/Sources/TPortal.php on line 18

I feel like I'm oh so close here ...

- Kevin
Title: Re: Integration and blocks
Post by: Zetan on June 05, 2007, 09:02:02 PM
When you say "Integration".. can you not put your custom app in an Article?
Title: Re: Integration and blocks
Post by: kmccann on June 05, 2007, 09:13:02 PM
Hi,

No, I cannot do this. My app is fairly big, has an admin interface, and always has a URLs like:

stats.php?op=somefunction&id=someid

The app has URL's throughout that point to itself. And I really do want it to be a standalone app that can be integrated into various CMS's (have done so with Postnuke and Xaraya). I really don;t want to change URL's throughout the app to SMF-specific URL's.

Here's the approach. The stats.php file is like so:

<?

include("SSI.php");
include("stats_includes/config.php");
include("stats_includes/dbopen.php");
include("stats_includes/tablenames.php");
include("stats/index.php");

?>

stats/index.php has all the "op" functions.

And it works great as far being able to use the SMF $contact[] variables by including SSI.php. This is how I conditionally populate the header's tab links. I just want to be able to do the same thing with TP by loading the functions within TPortal.php (like SSI.php). Then I can just call the function that brings up the left panel of blocks.

And, if I have a need to get access to other TPortal stuff, I can. Just gotta get over this hurdle.

Thanks,
Kevin
Title: Re: Integration and blocks
Post by: Zetan on June 05, 2007, 09:15:53 PM
I wouldn't know where to begin.. Have you asked this at SMF? TinyPortal is a mod for SMF. I'm not sure if your app can be packaged into a mod.
Title: Re: Integration and blocks
Post by: kmccann on June 05, 2007, 09:23:06 PM

It's actually quite TP-specific. The SMF part has been achieved (include SSI.php, get access to functions, get access to $context variables. I need to find out from a TP developer how I can load TP functions smoothly.

I did try to emulate SMF's index.php (which gets slightly modified by TP) by putting this in my stats.php file:

------------

$forum_version = 'SMF 1.1.2';

// Get everything started up...
define('SMF', 1);
@set_magic_quotes_runtime(0);
error_reporting(E_ALL);
$time_start = microtime();

// Load the settings...
require_once(dirname(__FILE__) . '/Settings.php');

// And important includes.
require_once($sourcedir . '/QueryString.php');
require_once($sourcedir . '/Subs.php');
require_once($sourcedir . '/Errors.php');
require_once($sourcedir . '/Load.php');
require_once($sourcedir . '/Security.php');
// TinyPortal include
require_once($sourcedir . '/TPortal.php');

------------------

but no luck. All kinds of nasty errors.

Any TP developers around who might be willing to help?