Help Required - Forum Specific Styles


Subject: Help Required - Forum Specific Styles
I made a mod so that the viewtopic.php file uses a different template dependant on the forum.
Say the sake of an example that is tries to use viewtopic_body2.tpl

Code: [Download] [Hide] [Select]
$template->set_filenames(array(
'body' => 'viewtopic_body'.$forum_style.'.tpl')
);

Where $forum_style has pulled some info out of the database.

What's strange is that the page loads but is still using the original viewtopic_body.tpl file but I don't know why.
It's not a database/php error, it's definitely replacing $forum_style with a valid value because I got errors saying viewtopic_body2.tpl didn't exist at first (until I made the file).
Is there an override to the set_filenames function?

Profile PM  
Subject: Re: Help Required - Forum Specific Styles
Is the viewtopic_body2.tpl actually any different to the original viewtopic_body.tpl? I mean, if using ca_aphrodite, the thing that actually changes the appearance is style_colo(u)r.css.

Profile PM  
Subject: Still Need Help Required - Forum Specific Styles
moreteavicar wrote: [View Post]
Is the viewtopic_body2.tpl actually any different to the original viewtopic_body.tpl?


LOL, seems a good question to ask. I thought I had thought of everything people were likely to ask me.
The css file just changes the classes assigned to tags in the template file.
The template file determines where everything is put and what things are put where etc.
My modified template does things like remove the avatar and the user info from the left of the post to give a much clearer page display.

In a nutshell, it'd be easy to see if the new template was being used

Profile PM  
Subject: Re: Help Required - Forum Specific Styles
Just wanted to make sure, as you know, ca_aphrodite uses a common pool of tpl files and does all its changes via css... ;)

The other issue I can think of at this time might be cache...

Or else there is a problem getting the variable $forum_style. Have you tried this just with, say,

$template->set_filenames(array(
'body' => 'viewtopic_body2.tpl')
);

and maybe add echo $forum_style; to see if a value is set...?

Profile PM  
Subject: Re: Help Required - Forum Specific Styles
It's a real mystery. I even turned the cache off and still have this same problem

Profile PM  
Subject: Re: Help Required - Forum Specific Styles
In phpBB XS you can try to attach the var ?s=XX to your url which should be the easiest way to have a dynamic style for each link you want, without modifying any TPL.

Make some tests and let me know. :wink:

Subject: Re: Help Required - Forum Specific Styles
Well, you're right, you can just stick that line of code in to override a style, which I didn't know before.
It completely overrides the choice to overide users choice of style too.

Although this is handy, it's not quite what I want. I'd need to set up an entire style for each different special forum type.

Thanks for pointing this out though.

I have fixed my problem again, basically I had put in a line which deleted my variable, so it was calling viewtopic_body.tpl every time, how silly :oops:

Profile PM  
Subject: Re: Help Required - Forum Specific Styles
Mmm... but where are you specifying the forum style? In the DB?

Or is it hardcoded in the files?

Subject: Re: Help Required - Forum Specific Styles
I'm specifying it in the DB as a new column in the forums table.
It's also changeable via the ACP in forums management

Profile PM  
Subject: Re: Help Required - Forum Specific Styles
Jarrod wrote: [View Post]
I'm specifying it in the DB as a new column in the forums table.
It's also changeable via the ACP in forums management

Ok, can I check your site to see what you did? :)

Subject: Re: Help Required - Forum Specific Styles
Mighty Gorgon wrote: [View Post]
Ok, can I check your site to see what you did? :)


Sure. Although you can't register or view the admin area, compare these two topics in different forums:
http://www.elaps.co.uk/viewtopic.php?t=91
http://www.elaps.co.uk/viewtopic.php?t=26
They're both using the ca_aphrodite (cyan) theme, but they use different template files for the the body of viewtopic
If you look around the site you'll probably see a couple of topics that display an error viewtopic_bodyxx.tpl doesn't exist (because I haven't finished them yet)

Profile PM  
Subject: Re: Help Required - Forum Specific Styles
Ops... sorry, I totally misunderstood what you wanted to do... ooops

I thought you would have changed the style, not the template file being parsed.

Nice to see you could reach your goal though.

Good work Jarrod.


Page 1 of 1


  
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events

   

This is a "Lo-Fi" version of our main content. To view the full version with more information, formatting and images, please click here.

Powered by Icy Phoenix based on phpBB
Generation Time: 0.1098s (PHP: 17% SQL: 83%)
SQL queries: 13 - Debug Off - GZIP Enabled