|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
gordonisnz Smarty Regular
Joined: 05 Sep 2009 Posts: 70
|
Posted: Fri Jan 22, 2021 10:36 pm Post subject: Choose template for small/big screens |
|
|
Hello.
Ive got 2 lots of HTML code, and i'm using CSS to display/hide the output depending on the size of the screen.
I am using the w3-css codes, w3-hide-medium and w3-hide-large etc...
--- SHOW ON SMALL SCREENS (hide on medium / large screens)
FOREACH
create HTML Code
/FOREACH
END CODE
--- HIDE ON SMALL SCREENS (show on medium / large screens)
FOREACH
create HTML Code
/FOREACH
END CODE
It works OK, HOWEVER i've effectively doubled the HTML code for each call of the page.
Is there a way to not display/create the HTML code at all - and only do one code in SMARTY depending on the size of the screen ?
I'm thinking of doing 1 code template for samll screens and another template for norml/big screens and themn using Samrty to choose a template.
Is this possible ? |
|
Back to top |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
Posted: Fri Jan 22, 2021 11:13 pm Post subject: |
|
|
Because Smarty compiles the template before sending it to the browser, Smarty will need to be told by some code in the PHP script of what the screen viewport size happens to be. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Mon Jan 25, 2021 12:27 pm Post subject: |
|
|
More specifically, Smarty has no way of knowing anything about browsers.
Do that in your HTML/CSS/JS code which runs directly in the browser. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|