Heh, can't really phrase this question in one sentence... please read :)

Started by jpaq, March 17, 2004, 12:58:54 AM

Previous topic - Next topic

jpaq

Ok, so my entire site is written in PHP.  I have a template for my site, written in PHP, that basically has all the menu code, the top graphics, and everything else in it.  In the template, there's a function called disp_content() that basically calls back to the original file, looking for the content.

So the flow of the site is like this:

User goes to /index.php

Index.php basically contains this code:

include('templates/main.php');

function disp_content {
some content here
}


My template file basically does this:

1) Display the header information....
2) Start a table, in the left column, display the menu
3) Open up the right column of the table
4) Call disp_content, to grab the contents from the calling file
5) Close the right colum, and the table
6) Cleanup and display copyright, etc.

Now, this worked out really well with the old template system.  Basically, my template file simply enclosed the "default" template in a disp_content() function, and the whole thing worked like a charm.

However, I want to use SMF in the same way, but I am not sure exactly how the new Theme system works, and where/when the functions in the new theme files get called.  How would I set up a Theme that does the same thing as my current system works?

Thanks for the help,

Jeff



[Unknown]

I guess the easiest, but also most inefficient, solution would be to have main_above empty, except for a ob_start();.  Then have main_below contain something like:

global $main;
$main = ob_get_contents();
ob_end_clean();

include_once('/path/to/templates/main.php');

And then have a function disp_content that just did:

global $main;
echo $main;

But I really think it would be better - efficiency-wise - if you copied the stuff from your existing template system to SMF's - above content and below.

-[Unknown]

jpaq

Heh, the goal here is really to eliminate having two versions of the template...

Maybe what I'll do is to create a sub-template called templates/main-split.php

Then I can have a top and bottom section in main-split, and my templates/main.php can simply call template_top(), disp_content(), template_bottom() and I'll just have the forum link to the main-split directly...  We'll see how it goes tomorrow (off to bed now)


jpaq

Actually, as it turns out a LOT of things have changed about the user verification and the flow of SMF vs. YaBBSE...  Bah, looks like I'm gonna have to rewrite most of my template from scratch...   Hopefully further updates don't change too much :P

On the plus side, things'll be a lot cleaner when I'm done.  (Under the current template I load SSI.php at the top so I can process logins and such, but can't do that on the forum pages so I have an if SCRIPT_URI is forum then don't load SSI, there's login verifications in two places, and a security level verification...)  Should be able to condense that all into 1 login verification and 1 security verification, and *SHOULD* if I'm reading the new code correctly be able to load SSI even on the forum pages without too much problem (as long as I load them in the correct order) ;)


[Unknown]

Wait, you can't load SSI.php in your templates?  Why not?

-[Unknown]

jpaq

Well, under YaBB I couldn't load SSI.php in the template *AND* load the forum's index.php on the same page...

BUT, I've gotten a lot of things rewritten, I'm now having a problem with logout.

I have taken the menu from the top of the forum and integrated it into my site's left hand navigation menu.  Doing that requires that I migrate the menu from the board template into my site template.  I rewrote the entire menu now to use $context but I have one problem:

When I go to put a Logout link in, the $context[session_id] returns a session ID that is wrong.  It's a valid ID, it's just not the same ID as I get from the regular menu for some reason...

Any ideas?


jpaq

Ok, nevermind...  /sheepish grin

I figured out the problem.  I forgot that I am set to always logged in to the YaBBSE installation, so I was having some conflicts as to which session_id was being returned by some things.  Logging out of YaBBSE cleared up this problem.


[Unknown]

I'm glad you got everything working.  Very good news.

-[Unknown]

jpaq

One last question, I promise...  Is there any way without modifying the code to get the SSI file to log you into/out of the forum but still return you to the page you were on when it's done instead of the forum index?

Thanks a lot for your help!


[Unknown]


jpaq


[Unknown]

Well, you have to set the cookies yourself but at least it helps ;).

-[Unknown]

Advertisement: