Conditionals/Forums on every pages ?

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
User avatar
ZYVHK
Registered User
Posts: 48
Joined: Sat Jul 15, 2017 1:38 am
Location: France
Name: Lucas

Conditionals/Forums on every pages ?

Post by ZYVHK »

Hey there,
I'm hesitating with choosing PhpBB for my project. I was wondering if there were conditionals (conditional statements) for the templates?

Thanks.
Last edited by ZYVHK on Tue Nov 10, 2020 1:06 pm, edited 3 times in total.
User avatar
david63
Registered User
Posts: 18582
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Contact:

Re: Conditionals ?

Post by david63 »

phpBB now used Twig as its templating engine so you can do quite a bit of processing within the template - if that answers your question.
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored
User avatar
ZYVHK
Registered User
Posts: 48
Joined: Sat Jul 15, 2017 1:38 am
Location: France
Name: Lucas

Re: Conditionals ?

Post by ZYVHK »

david63 wrote:
Mon Nov 09, 2020 1:38 pm
phpBB now used Twig as its templating engine so you can do quite a bit of processing within the template - if that answers your question.
Oy,
Thanks for the quick reply.

I'll be honest, I'm not very informed about things such as Twig.
To be more precise, here's an example of conditional coming from another forum software:
<xf:if is="$xf.visitor.is_admin">[/INDENT]
[INDENT=2] Show content...[/INDENT]
[INDENT=2]</xf:if>
User avatar
david63
Registered User
Posts: 18582
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Contact:

Re: Conditionals ?

Post by david63 »

Yes you will be able to use if statements in a phpBB template - in fact you always have.

Some light reading - https://twig.symfony.com/
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored
User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 4253
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.
Contact:

Re: Conditionals ?

Post by thecoalman »

View the source: styles/prosilver/template/overall_header.html

The <!-- IF S_ENABLE_FEEDS --> as one example is from phpBB's own templating engine. It's pretty basic and easy to understand.

Tutorial here: https://wiki.phpbb.com/Tutorial.Template_syntax

You can also use Twig syntax but I'm not that familiar with it.
“Results! Why, man, I have gotten a lot of results! I have found several thousand things that won’t work.”

Attributed - Thomas Edison
User avatar
ZYVHK
Registered User
Posts: 48
Joined: Sat Jul 15, 2017 1:38 am
Location: France
Name: Lucas

Re: Conditionals ?

Post by ZYVHK »

Thank you for your replies, seems like I'm going to have fun with phpbb. ♥
User avatar
ZYVHK
Registered User
Posts: 48
Joined: Sat Jul 15, 2017 1:38 am
Location: France
Name: Lucas

Show forums on each and every pages

Post by ZYVHK »

Hey there,
I've been attempting for a few hours to show every forums on every pages by including the line <!-- INCLUDE forumlist_body.html --> in the overall_header template after having it removed from the index one.

The forums will obviously still show on the index page, but they won't show anymore on any other page, showing the text "No forums." instead.
Any idea how this could be achieved ?

Thank you.
Last edited by thecoalman on Tue Nov 10, 2020 7:10 am, edited 1 time in total.
Reason: Merged with existing topic.
User avatar
stevemaury
Support Team Member
Support Team Member
Posts: 51679
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve
Contact:

Re: Show forums on each and every pages

Post by stevemaury »

Did you purge the cache after editing the HTML file? You need to.
For REALLY good and VERY inexpensive hosting CLICK HERE

I can stop all your spam. I can upgrade or update your Board. PM or email me. (Paid support)
User avatar
ZYVHK
Registered User
Posts: 48
Joined: Sat Jul 15, 2017 1:38 am
Location: France
Name: Lucas

Re: Show forums on each and every pages

Post by ZYVHK »

stevemaury wrote:
Mon Nov 09, 2020 11:34 pm
Did you purge the cache after editing the HTML file? You need to.
Yup. Some screenshots in case the explanations weren't clear enough:

On the index: the (currently unique) forum shows itself:
Image

On any other page (in this case: inside the subforum), it says No forums:
Image
User avatar
Lumpy Burgertushie
Registered User
Posts: 68296
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Show forums on each and every pages

Post by Lumpy Burgertushie »

did you give the registered user group permissions to see those forums?

did you create a forum or a category?
if a category then you have to have a forum inside it before you will see that category etc.

robert
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.3 Styles by PlanetStyles.net

If nobody is in the forest, does a tree really fall?
User avatar
ZYVHK
Registered User
Posts: 48
Joined: Sat Jul 15, 2017 1:38 am
Location: France
Name: Lucas

Re: Show forums on each and every pages

Post by ZYVHK »

Lumpy Burgertushie wrote:
Tue Nov 10, 2020 12:30 am
did you give the registered user group permissions to see those forums?

did you create a forum or a category?
if a category then you have to have a forum inside it before you will see that category etc.

robert
Hey,
It seems my goal isn't clear enough.

What I would like to do is some kind of always-visible forums navigation that would allow users to see every forums they have access to and see the lastposts, forums descriptions, messages number and everything on any page.
User avatar
Lumpy Burgertushie
Registered User
Posts: 68296
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Show forums on each and every pages

Post by Lumpy Burgertushie »

well, after my post above, I made the edits to the two files, moving the forumlist to the overall header file.

just as you have seen, I too get the no forums message in that spot.

not sure why it does that, but I suppose someone will come along that can explain it .

robert
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.3 Styles by PlanetStyles.net

If nobody is in the forest, does a tree really fall?
User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 4253
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.
Contact:

Re: Conditionals ?

Post by thecoalman »

Template variables are only available on certain pages so you can't just include any template or template variable.

If you open includes/functions.php and go down to about line 4550:

Code: Select all

	// The following assigns all _common_ variables that may be used at any point in a template.
	$template->assign_vars(array(
		'SITENAME'						=> $config['sitename'],
		'SITE_DESCRIPTION'				=> $config['site_desc'],
		'PAGE_TITLE'					=> $page_title,
That's a pretty long list and only those template variables are available anywhere. Each main page has it's own set of template variables. If you open index.php and near the bottom:

Code: Select all

	'S_INDEX'					=> true,
So for example if you had this in the template overall_header.html

Code: Select all

<!-- IF S_INDEX -->
{SITENAME}
<!-- ENDIF -->
The site name would display on pages in that location just on index.php

Specifically with the forum list the first line in that template is:

Code: Select all

<!-- BEGIN forumrow -->
This starts a loop, forumrow contains an array of data for each forum, Since the data for this array is only populated for index.php and I believe viewforum.php if it's category it will only produce results for that page.

As side note the reason you don't simply populate that data is because it requires more server resources. It's certainly possible to do what you want to do but I'll leave that to someone more qualified if they want to answer.
ZYVHK wrote:
Tue Nov 10, 2020 12:41 am
What I would like to do is some kind of always-visible forums navigation that would allow users to see every forums they have access to and see the lastposts, forums descriptions, messages number and everything on any page.
The jumpbox is displayed on most pages. You could create your own template using the data from that array. It's not going to have post counts, forum description etc. but minimally it has forum name and data to link to it. Beyond that you would need to edit php files.
“Results! Why, man, I have gotten a lot of results! I have found several thousand things that won’t work.”

Attributed - Thomas Edison
User avatar
ZYVHK
Registered User
Posts: 48
Joined: Sat Jul 15, 2017 1:38 am
Location: France
Name: Lucas

Re: Conditionals ?

Post by ZYVHK »

Thanks for the clear explanations thecoalman. Hopefully someone can come with a solution as this is something I really wish to do.
The jumpbox could be an alternative, but a poor one (no offense) :/
User avatar
RMcGirr83
Former Team Member
Posts: 21693
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: Show forums on each and every pages

Post by RMcGirr83 »

ZYVHK wrote:
Tue Nov 10, 2020 12:41 am
What I would like to do is some kind of always-visible forums navigation that would allow users to see every forums they have access to and see the lastposts, forums descriptions, messages number and everything on any page.
viewforum, viewtopic, posting, memberlist, viewonline, user control panel, faq, etc? No offense but personally that would drive me completely insane.
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
Appreciate the extensions/mods/support then buy me a beerImage
Post Reply

Return to “phpBB Custom Coding”