Changing forum banner according to connection status.

For support and discussion related to templates and themes in phpBB 3.3.
Post Reply
pitibonom
Registered User
Posts: 57
Joined: Thu Feb 09, 2012 3:59 pm

Changing forum banner according to connection status.

Post by pitibonom »

Hi all :)

I got a phpBB forum that i forbid to guests.
On that forum there's a banner. I'd like this banner to be different when the user is unconnected ( guest ) or connected ( member ).

Is there a way ( even by modifying php ) to do this ?

Thanks in advance !

Regards.
Last edited by thecoalman on Tue Sep 28, 2021 1:27 pm, edited 1 time in total.
Reason: Moved to Styles Support & Discussion
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53398
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Changing forum banner according to connection status.

Post by Brf »

You could use the S_USER_LOGGED_IN flag around your site_logo span in overall_header.html
pitibonom
Registered User
Posts: 57
Joined: Thu Feb 09, 2012 3:59 pm

Re: Changing forum banner according to connection status.

Post by pitibonom »

oh i guess this sounds like exactly what i need :)

However how would you use such a flag un html ?
There's some bool example in header.html:

Code: Select all

data-skip-responsive="true"data-last-responsive="true"> {L_FAQ}
but i don't know what it is done for :/

Could you please gimme an example ? something like

if( S_USER_LOGGED_IN )
Banner1
else
Banner2

hmm i'm a C++ code writer but i know things are not like this in html :oops:

Thanks :)
User avatar
Sniper_E
Registered User
Posts: 1134
Joined: Wed May 09, 2007 12:18 am
Location: Shreveport, Louisiana
Name: Ed Humphrey
Contact:

Re: Changing forum banner according to connection status.

Post by Sniper_E »

In overall_header.html like Brf said maybe something like...
<!-- IF S_USER_LOGGED_IN --><span class="site_logo"></span><!-- ELSE --><span class="site_logo_guest"></span><!-- ENDIF -->
Then add your css for guest banner in your stylesheets.

What does your overall_header code look like?
Image . -.. / .... ..- -- .--. .... .-. . -.--
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!

:!: Sniper_E Styles | phpbbmodders :!:
pitibonom
Registered User
Posts: 57
Joined: Thu Feb 09, 2012 3:59 pm

Re: Changing forum banner according to connection status.

Post by pitibonom »

replying to myself with the solution.

Thanks a lot @brf and @Sniper_E !!!!

I replaced the banner code with:

Code: Select all

   <!-- IF S_USER_LOGGED_IN -->
	<a href="{% if U_SITE_HOME %}{{ U_SITE_HOME }}{% else %}{{ U_INDEX }}{% endif %}" title="{% if U_SITE_HOME %}{{ L_SITE_HOME }}{% else %}{{ L_INDEX }}{% endif %}">
		<div class="carbon-topper"></div><img src="{T_THEME_PATH}/images/carbon-logo.jpg" class="carbon-image-wrapper" alt="">
	</a>
   <!-- ELSE -->
	<a href="{% if U_SITE_HOME %}{{ U_SITE_HOME }}{% else %}{{ U_INDEX }}{% endif %}" title="{% if U_SITE_HOME %}{{ L_SITE_HOME }}{% else %}{{ L_INDEX }}{% endif %}">
		<div class="carbon-topper"></div><img src="{T_THEME_PATH}/images/carbon-logo-guest.jpg" class="carbon-image-wrapper" alt="">
	</a>
	<!-- ENDIF -->
An i realized what amazing things are possible over here :lol:

However i would have never thought that comments tags <!-- and --> were used as control code in PHP :roll:

Now this works like a charm:
Unconnected user: banner1.jpg
Connected user: banner2.jpg

@Pitibonom HAPPY !!!


Have nice day :)
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: Changing forum banner according to connection status.

Post by david63 »

pitibonom wrote: Tue Sep 28, 2021 9:56 am However i would have never thought that comments tags <!-- and --> were used as control code in PHP
They are not - they are in html
David
Remember: You only know what you know and - you don't know what you don't know!

I now no longer support any of my extensions but they will start to become available here
User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 5871
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.
Contact:

Re: Changing forum banner according to connection status.

Post by thecoalman »

pitibonom wrote: Tue Sep 28, 2021 9:56 am An i realized what amazing things are possible over here :lol:
If you open includes/functions.php , near the end of the file you'll find a long list of common template variables. Each individual file, viewforum.php for example, will have it's own list of template variables available at the end of the file. For example one of them is S_VIEWFORUM which you could use to display something in overall_header.html only for viewforum.php. The variables prepended with S_ are switches set to to true of false, the ones with L_ are from the language files. Most of the others hold values or arrays.

https://wiki.phpbb.com/Tutorial.Template_syntax
However i would have never thought that comments tags <!-- and --> were used as control code in PHP :roll:
That's from phpBB's custom template engine starting with phpBB 2.0 in the early 2000's. phpBB also supports Twig syntax and I suspect that phpBB's template engine will get the axe in the future.

If you actually wanted to make a comment that is not going to appear in the HTML output or comment out HTML you can use:

Code: Select all

<!-- IF 0 -->Comment text or some code to be removed<!-- ENDIF -->
“Results! Why, man, I have gotten a lot of results! I have found several thousand things that won’t work.”

Attributed - Thomas Edison
Post Reply

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