phpBB Standalone Template Engine

Discussion forum for MOD Writers regarding MOD Development.
squeek
Registered User
Posts: 173
Joined: Sat Jan 20, 2007 12:43 am

Re: phpBB Standalone Template Engine

Post by squeek »

i figured that and had done it while i was waiting for a reply but im sure it may help others who view this thread. thanks for your reply its much appreciated.
caloooom
Registered User
Posts: 17
Joined: Sat Dec 12, 2009 7:15 am

Re: phpBB Standalone Template Engine

Post by caloooom »

Hello,

I've tried to install this mod and was it was all going well... Until I hit this error on my index page.
Fatal error: Cannot redeclare class template in /home/******/public_html/cat3/classes/template.php on line 24
I tried removing this line, but then I get another error:
Parse error: syntax error, unexpected T_VAR in /home/*******/public_html/cat3/classes/template.php on line 31
Can someone please help :) Thanks a lot! :D
nanothree
Registered User
Posts: 262
Joined: Wed Dec 10, 2003 8:33 am
Location: Doncaster, UK
Contact:

Re: phpBB Standalone Template Engine

Post by nanothree »

it looks like the template class is already been included.

Try switching your

Code: Select all

include('/path/to/template.php')
with:

Code: Select all

include_once('/path/to/template.php')
User avatar
igorw
Former Team Member
Posts: 8024
Joined: Fri Dec 16, 2005 12:23 pm
Location: {postrow.POSTER_FROM}
Name: Igor Wiedler

Re: phpBB Standalone Template Engine

Post by igorw »

No, it's a parse error. Most likely you made a mistake with one of the edits.
Igor Wiedler | area51 | GitHub | trashbin | Formerly known as evil less than three
caloooom
Registered User
Posts: 17
Joined: Sat Dec 12, 2009 7:15 am

Re: phpBB Standalone Template Engine

Post by caloooom »

eviL<3 wrote:No, it's a parse error. Most likely you made a mistake with one of the edits.
That's most likely my problem. I had difficulty with the first step.. :oops: Very novice, I know.

I honestly wasn't sure how to compile "includes/template.php" and "functions_template.php" into the one "includes/template.php" file.

I also didn't find the directory structuring very clear either. If someone could help me on both of those points, I'm sure I'll be good to go :)
User avatar
Rotsblok
Registered User
Posts: 648
Joined: Fri Nov 11, 2005 12:47 pm
Location: Upper north of Holland
Name: Rikkert Westa
Contact:

Re: phpBB Standalone Template Engine

Post by Rotsblok »

I have a question...

If I want to have multiple styles which are defined by the user (UCP).. Can I just define the phpbb_root_path and make the same structure as for phpBB (styles/stylename/template etc) and does it switch when the user changes the style? or do I also need to define $user...

Personally I think I need to define $phpbb_root_path and include functions_user.php for $user... but as I'm no php expert I'm not really sure if it will work...
Nederlandse Support site
Several dutch translations for 3.1 extensions if you need one or there is an update of an extension feel free to notify me.
nanothree
Registered User
Posts: 262
Joined: Wed Dec 10, 2003 8:33 am
Location: Doncaster, UK
Contact:

Re: phpBB Standalone Template Engine

Post by nanothree »

caloooom: I've PM'd you about your issue.

Rotsblok: Do you want to use the phpBB UCP? This post is about using the template system outside of phpBB.

Anyway, here is how i have multiple styles defined by the user:

Code: Select all

if(isset($_GET['user_style'])){
	$style = $_GET['user_style'];
}else{
        $style = 'dark_red';
}

$template = new Template();

$template->set_custom_template('styles/' . $style, 'default');

This allows the theme to be changed via the URL. You could just as easily get the style from a database.

In the above example if no style is set in the $_GET array then a default (dark_red) is used.

Hope that helps
User avatar
Rotsblok
Registered User
Posts: 648
Joined: Fri Nov 11, 2005 12:47 pm
Location: Upper north of Holland
Name: Rikkert Westa
Contact:

Re: phpBB Standalone Template Engine

Post by Rotsblok »

I mean using the users defined style (which he standard can set in the UCP like on a normal vanilla phpBB).

So if user A wants subSilver2 to be the style, that not only the board style is subSilver2 but also the standalone (main site) is subSilver2.

But I just realized that I can better use the full site integration topic... :oops:
Nederlandse Support site
Several dutch translations for 3.1 extensions if you need one or there is an update of an extension feel free to notify me.
nanothree
Registered User
Posts: 262
Joined: Wed Dec 10, 2003 8:33 am
Location: Doncaster, UK
Contact:

Re: phpBB Standalone Template Engine

Post by nanothree »

yes, that would probably be best. This topic is just about using the template class on its own. Full integration is the best way to go for you, or anybody running a phpBB board on their site.

I'd suggest using this topic only if you wanted to use the template class without using phpBB at all.

Could you post a link to the topic you are talking about and i can put a link to it in the first post.

Thanks
User avatar
imkingdavid
Former Team Member
Posts: 2672
Joined: Sun Jul 26, 2009 7:59 pm
Location: EST
Name: David King

Re: phpBB Standalone Template Engine

Post by imkingdavid »

@nanothree: 3.0.6 changed the code for the first find in your first post as well, and I just caught it.

In phpBB 3.0.6 the code you should be looking for is:

Code: Select all

$this->files_template[$handle] = (isset($user->theme['template_id'])) ? $user->theme['template_id'] : 0;
Comment that out.

Also, because there was a request for it, I have put all of the code required into a .php file on my server. Just right-click on the link provided below and click Save As... and it will download all of the code to your computer. This should make it easier for people instead of having to go consolidate the code themselves. NOTE: All of the changes detailed in the first post have been made in the code below.

EDIT: see a few posts down for updated link.

I hope this helps!
Cheers!
-david
Last edited by imkingdavid on Sun Jan 10, 2010 5:15 am, edited 2 times in total.
Don't forget to smile today. :)
Please do NOT contact for support via PM or email.
User avatar
igorw
Former Team Member
Posts: 8024
Joined: Fri Dec 16, 2005 12:23 pm
Location: {postrow.POSTER_FROM}
Name: Igor Wiedler

Re: phpBB Standalone Template Engine

Post by igorw »

Renaming it to template_class.php.txt may be helpful. :)
Igor Wiedler | area51 | GitHub | trashbin | Formerly known as evil less than three
nanothree
Registered User
Posts: 262
Joined: Wed Dec 10, 2003 8:33 am
Location: Doncaster, UK
Contact:

Re: phpBB Standalone Template Engine

Post by nanothree »

Thanks David,

I kept meaning to post a link to the file but never got round to doing it.

I cant get the file form your server, do what evil said and upload it as a text file, then i'll add it to to the first post

Thanks
User avatar
imkingdavid
Former Team Member
Posts: 2672
Joined: Sun Jul 26, 2009 7:59 pm
Location: EST
Name: David King

Re: phpBB Standalone Template Engine

Post by imkingdavid »

Yeah my bad, my server has been down all day because my host ran into trouble while upgrading or something.

I'll upload the file as a text file for you once the site is back up. :)
Don't forget to smile today. :)
Please do NOT contact for support via PM or email.
User avatar
imkingdavid
Former Team Member
Posts: 2672
Joined: Sun Jul 26, 2009 7:59 pm
Location: EST
Name: David King

Re: phpBB Standalone Template Engine

Post by imkingdavid »

Alright, my server's back up. Click the following link to get the file: template_class.php.txt
Don't forget to smile today. :)
Please do NOT contact for support via PM or email.
Hexcode
Registered User
Posts: 77
Joined: Fri Apr 10, 2009 4:51 pm
Location: Cologne, Germany

Re: phpBB Standalone Template Engine

Post by Hexcode »

Can someone tell me how to make a whileloop in it?
Locked

Return to “[3.0.x] MOD Writers Discussion”