Template Variables - mobile or desktop

For support and discussion related to templates, themes, and imagesets in phpBB 3.2.
Post Reply
kaerol
Registered User
Posts: 7
Joined: Sat Feb 20, 2016 3:48 pm

Template Variables - mobile or desktop

Post by kaerol »

Hi!

here
https://forums.thetopfew.com/viewtopic.php?t=739
https://wiki.phpbb.com/Category:Template_Variables

are some variable which can be used in html template in this way:

<!-- IF S_USER_LOGGED_IN -->
<!-- ENDIF -->

I'm looking for variable which define if forum is open on mobile (or desktop).

I didn't find on provided sites.
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: Template Variables - mobile or desktop

Post by david63 »

As far as I am aware there is no core template variable to indicate whether you are using a mobile device or a desktop computer - this is all handled with .js and .css files.
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
Lumpy Burgertushie
Registered User
Posts: 69223
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Template Variables - mobile or desktop

Post by Lumpy Burgertushie »

please explain what you want for the final outcome of what you are trying to do.
why do you want to be able to know this?
what are you going to do with that information if and when you get it?

robert
Premium phpBB 3.3 Styles by PlanetStyles.net

I am pleased to announce that I have completed the first item on my bucket list. I have the bucket.
User avatar
PlanetStyles.net
Former Team Member
Posts: 4809
Joined: Wed Nov 04, 2009 11:16 pm
Location: Way up in the sky close to the stars
Name: Christian
Contact:

Re: Template Variables - mobile or desktop

Post by PlanetStyles.net »

Depending on what you're trying to achieve, displaying content to users dependant on their device can easily be achieved with CSS selectors.

By default prosilver includes the following:

Code: Select all

<div class="responsive-show" style="display: none;">This will be hidden on desktop but show on mobile</div>

<div class="responsive-hide">This will be shown on desktop but hidden on mobile</div>
If you're looking to use either of these in content, you could incorporate them into custom BBCodes :)
User avatar
Hanakin
Front-End Dev Team Lead
Front-End Dev Team Lead
Posts: 1065
Joined: Wed Dec 30, 2009 8:14 am
Name: Michael Miday
Contact:

Re: Template Variables - mobile or desktop

Post by Hanakin »

i would, however, recommend using CSS media queries instead of those classes as those are problematic seeing as how the randomly behave according to some nasty JS code fooery
kaerol
Registered User
Posts: 7
Joined: Sat Feb 20, 2016 3:48 pm

Re: Template Variables - mobile or desktop

Post by kaerol »

Sorry for long - silence.

Using css in not so good because it's just hide some code.
But I want to not to render it when mobile.

I have some menu item that open iframe - and its look very bad on mobile so I want to not display this menu item.

Thanks!
User avatar
Hanakin
Front-End Dev Team Lead
Front-End Dev Team Lead
Posts: 1065
Joined: Wed Dec 30, 2009 8:14 am
Name: Michael Miday
Contact:

Re: Template Variables - mobile or desktop

Post by Hanakin »

then js is how you would need to do this. you can try loading it on the page via an ajax call depending on if there are now template variables in it. if then you will have to rework the desktop version with js dom manipulation.
User avatar
Lumpy Burgertushie
Registered User
Posts: 69223
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Template Variables - mobile or desktop

Post by Lumpy Burgertushie »

kaerol wrote: ↑Wed Jan 24, 2018 9:35 pm Sorry for long - silence.

Using css in not so good because it's just hide some code.
But I want to not to render it when mobile.

I have some menu item that open iframe - and its look very bad on mobile so I want to not display this menu item.

Thanks!
so what is wrong with hiding the code for the menu item? if the particular menu item is hidden when the screen gets smaller then nobody can click on it and therefore the iframe that your menu item produces will never be shown on the smaller device.
maybe I missed something.


robert
Premium phpBB 3.3 Styles by PlanetStyles.net

I am pleased to announce that I have completed the first item on my bucket list. I have the bucket.
kaerol
Registered User
Posts: 7
Joined: Sat Feb 20, 2016 3:48 pm

Re: Template Variables - mobile or desktop

Post by kaerol »

Maybe it's old school, It's waste of bandwidth for items which won't show.

And sometimes its can be show by others just by modify css with some developers tools.

In this particular problem maybe solution with js/css is good enough.

But sometimes its good to see the big picture
User avatar
Lumpy Burgertushie
Registered User
Posts: 69223
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Template Variables - mobile or desktop

Post by Lumpy Burgertushie »

either way you are not saving any bandwidth or disk space. the code has to be somewhere for either show or don't show.
It seems that trying to do it the way describe will actually double up code and therefore space/bandwidth etc.


robert
Premium phpBB 3.3 Styles by PlanetStyles.net

I am pleased to announce that I have completed the first item on my bucket list. I have the bucket.
kaerol
Registered User
Posts: 7
Joined: Sat Feb 20, 2016 3:48 pm

Re: Template Variables - mobile or desktop

Post by kaerol »

If in template is one of these:

<!-- IF U_ACP --> ADMIN <!-- ENDIF -->
<!-- IF S_USER_LOGGED_IN --> LOGGED <!-- ENDIF -->

then elements ADMIN, LOGGED are cut from html when user don't have permissions.
So I looked for something like above, without success.

But I used the solution proposed by Christian 2.0 and its good for my needs.
User avatar
Hanakin
Front-End Dev Team Lead
Front-End Dev Team Lead
Posts: 1065
Joined: Wed Dec 30, 2009 8:14 am
Name: Michael Miday
Contact:

Re: Template Variables - mobile or desktop

Post by Hanakin »

It’s not a waste of bandwidth if it’s in the html as that’s 100% cached vs if you use js to manipulate the dom after the fact it’s not! Also html 2.0 makes all your concerns obsolete with multithreading meaning I can load more than one css js img file at the same time as apposed to now where it’s queued
Post Reply

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