Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Choose template for small/big screens

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
gordonisnz
Smarty Regular


Joined: 05 Sep 2009
Posts: 70

PostPosted: Fri Jan 22, 2021 10:36 pm    Post subject: Choose template for small/big screens Reply with quote

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
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Fri Jan 22, 2021 11:13 pm    Post subject: Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Mon Jan 25, 2021 12:27 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP