News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Intergrating SMF, $scripturl

Started by himdumb, January 20, 2008, 03:17:41 PM

Previous topic - Next topic

himdumb

Hello,
I'm trying to integrate SMF into a website for someone.  It is setup with a Header, Left Menu, Right Main Area, and the footer.  I would like to make forum appear in the main window.

The site is setup like:
http://mysite/?show=whatever

And 'whatever' would me displayed in the Right Main Area.

I would like to make the forum appear in this Right Main Window.  But i cant figure it out.

I set it up, so ?show=Forum would "include ('forum/index.php');"  And that works once..but any links take over the whole page, unless i edit all the links to be '?show=Forum&action=' instead of just '?action='...and the .css from index messes the whole site.

I also tried setting $boardurl (i think thats the one) to 'http://mysite.com [nofollow]' instead of 'http://mysite.com/forum' [nofollow];, but that makes the urls bad (adds /index.php to it) and makes it not work.

Is there a simple way to do this? Maybe messing with $scripturl (that seems to be what messes it up).

Maybe using loadTemplate('BoardIndex') (or profile, or whatever)...but i couldnt get that to work either...


Thanks,
himdumb

Orstio

There isn't a simple way to do this.

Simply modifying $scripturl would be the wrong thing to do.

What you'll need to do is buffer the output of SMF, and then do a str_replace on all the URLs in the buffer before outputting it.

himdumb

Thats the best way?

There is noway to just include the BoardIndex? or Profile, messages, admin...in my source?

By loading the template, or including a file, or anything?

Ill check into the str_replace/buffer method.

Thanks,
himdumb

Orstio

It is the best way.

Everything falls through SMF's index.php.  You can't use the profile or messages or admin panel without going through SMF's index.php.

himdumb

Ok, ive tried doing the str_replace thing.  But im not sure how.

If i do something like:
Quote$file = file('forum/index.php');

$replaced = str_replace('forum/index.php?action=', '?show=Forum&action=',$file)

echo $replaced

it outputs the file like .txt (no processing of the php commands)

and if i 'include' instead of 'file', then it outputs the file before i can str_replace it...

So what am i doing wrong?  Im sure its something simple on my end...

Thanks again for all the help,
himdumb

Orstio

It gets a little more complicated than that, even.

First, you need to start up a buffer for output:

ob_start();

Then, you can do your include:

require('forum/index.php');

Then, you put the contents of the buffer into a variable, and dispose of the buffer:

$buffer = ob_get_contents();
ob_end_clean();


Now, you have the contents of the output of SMF in the variable $buffer.

himdumb

I tried using your example (and a few different examples from php.net [nofollow]), but it never outputs anything to the browser.  Unless theres an error.

I used your exact code, with:  echo $buffer;

And its just a blank browser window.

Ill continue looking and trying stuff.  But any more help would be greatly appreciated.

Thanks,
himdumb 

Orstio


himdumb

Quoteob_start();
require('forum/index.php');
$buffer = ob_get_contents();
ob_end_clean();

$replace = "/forum/index.php?action=";
$with = "/?show=Forum&action=";

$buffer2 = str_replace($replace, $with, $buffer);

echo $buffer2;

Just using "require('forum/index.php');" works fine  (well, as expected.  It doesnt replace the links)...

Thanks

Orstio

Is there anything in your forum error log?

himdumb

#10
Nope....

But if i put an 'echo' in front of the ob_start, it works.  But it puts a '1' (SUCCESS?), before it displays the index.php?!?!?

I dont get it.?

Any help appreciated.

Youre great Orstio, thanks alot!

Orstio

Oh!  In order to make this work, you're going to have to turn off compressed output in SMF.

himdumb

?!?!?!!?

It works fine, except for the '1' before it shows index.php...

is there a way to make it not show the '1'...and i dont know why i have to echo the od_start..is that why i need the compression off?

Orstio

You are currently working with a compressed (gzip) output buffer. 

You need to be working with a plain text output.

The echo you put in before the ob_start is just breaking the buffer.

himdumb

It works!  Thanks for walking me through, and explaining it all.

himdumb

Orstio

No problem.  It's a pleasure to see somebody discovering how to create their own bridge.

When you need more help, feel free to ask. ;)

himdumb

Ok, i gots a problem...It doesnt work with the way SMF works with pictures.  It works with the ones in the themes dir, but not avatars or the verification code...theres proably more.

Are there any other images i need to search for besides:
action=verificationcode
action=dlattach

Or certain dir(s)?


Orstio

QuoteAre there any other images i need to search for besides:
action=verificationcode
action=dlattach

Yup, you'll need to leave those URLs out of the conversion.

I've found that in some cases it's easier to convert them all, and then just convert those few URLs back after.

himdumb

Awesome.  Thanks alot man.

himdumb

himdumb

Ok, i have another problem that i cant figure out.

Some of the buttons go to /forum/index?action=...instead of ?show=Forum&action=

A few that i noticed are, going to the admin section, when it ask for my pass (i think after i have been logged in for a certain time ?), and when you update you profile (the 'Change Profile' button).

I cant find where the urls are formed, or if my current replace method will work.

I gonna try and sort through some more of this code.  Any help is greatly appreciated.

himdumb

Advertisement: