Creating New Conditionals for Templates

For support and discussion related to templates, themes, and imagesets in phpBB 3.0.
Ideas Centre
Locked
Friendly
Registered User
Posts: 66
Joined: Tue May 06, 2008 12:21 pm

Creating New Conditionals for Templates

Post by Friendly »

My phpbb (3.3) installation is contained inside a CMS, and is located at /forum. I have a template with some tabs across the top for various sections of my site. One of the tabs is 'blog'. Now, the way my site works is that if you are on any page other than the forum, the CMS controls everything. I have duplicated the PHPBB style as a template inside my CMS. So on any page other than the forum, the CMS adds a class of 'active' to the <li> tag, enabling me to give an active state to the tab for the page I am on. And when the user is on the forum page, the PHPBB style kicks in. The PHPBB style has class='active' hard coded into the template in the <li> tab for forum. This means that any time the user is anywhere in the forum, the 'forum' tab shows up as active.

Now to the problem: I just installed the 'user blog' mod, as the blog functions on it are much better than on the CMS I am using. But, when the user is at the blog section, the URL they are at is /forum/blog. This means that even when they are in the blog, they are still in the PHPBB section of the site, and not the external CMS section of the site. So although they are in the 'blog' section of the site, the 'forum' tab shows up as being the active tab, as the template being used is the PHPBB template and not the CMS template.

So what I want to do is add a conditional to my PHPBB template. If the user isn't in the blog section, then I want to add class="active" to the <li> tag for the forum. And if the user is in the blog, I want to add class="active" to the <li> tag for the blog.

But I really don't know where to begin with this. I'm quite proficient at PHP, so it's natural for me to just want to add PHP to my template page. But having done a lot of modifications to PHPBB I've started to get an idea of how it all fits together, and I can see that adding php to the template file just isn't going to work. What I do want to do is create one of the conditional comments that they have in the templates, ex:

<!-- IF U_PRINT_TOPIC -->

But I don't know where or how to create this conditional. I'm hoping someone can point me in the right direction. I don't expect anyone to write the code for me, as I most likely can do it myself if I get some pointers. But the main points I'm wondering are:

1) What file(s) should I create the code in? And is there a special location in that/those file(s) that I should be creating this code?
2) How exactly are these conditionals created? They must be created in PHP and passed to the template somehow to work using the conditional comment code. Can someone give me an example (even a simple one).

Thank you very much.
ToonArmy
Former Team Member
Posts: 4608
Joined: Sat Mar 06, 2004 5:29 pm
Location: Worcestershire, UK
Name: Chris Smith
Contact:

Re: Creating New Conditionals for Templates

Post by ToonArmy »

Chris SmithGitHub
Friendly
Registered User
Posts: 66
Joined: Tue May 06, 2008 12:21 pm

Re: Creating New Conditionals for Templates

Post by Friendly »

Thanks, that's a good nudge in the right direction. But I'm still left unclear as to which file I should add my code to. The template I want to have the conditional inside is overall_header. Should I add the code to functions.php? Or is there a better page to add the code to?
Friendly
Registered User
Posts: 66
Joined: Tue May 06, 2008 12:21 pm

Re: Creating New Conditionals for Templates

Post by Friendly »

I ended up adding the code to includes/functions.php, and it works. Thanks for the link ToonArmy.
Locked

Return to “[3.0.x] Styles Support & Discussion”