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

SOLVED - Use viewport or media query with smarty

 
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
Akede
Smarty n00b


Joined: 28 Jan 2016
Posts: 3

PostPosted: Thu Jan 28, 2016 7:00 pm    Post subject: SOLVED - Use viewport or media query with smarty Reply with quote

I've got an online shop (shopware 5), where smarty templates are used.

I created some containers with text in them.
The width is fixed, but I want the height of the container to be specific depending on whether the visitor is browsing my shop on his desktop or on his mobile phone / tablet (portrait or landscape view).

So the code in the template looks like this:
Code:
...
{if $template == 'component_html'}
height: auto;
{else}
height: {$itemHeight / 16}rem;
{/if}
...


'component_html' declares a container in my shop system.
It contains HTML and therefore it can contain text.

What I want to have is something like this:
Code:
...
{if $template == 'component_html' AND viewport == mobile device}
...


or
Code:
...
{if $template == 'component_html' AND media query == < (smaller than) 1280px}
...



Is this possible with Smarty? How's the exact Code for AND ( || ?) and for media query or viewport (whatever works best...)?

Thank you in advance.


Last edited by Akede on Fri Jan 29, 2016 5:34 pm; edited 1 time in total
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Jan 28, 2016 8:57 pm    Post subject: Reply with quote

You shouldn't put any such logic into your code.
Just fix your CSS for each case.
http://www.w3schools.com/cssref/css3_pr_mediaquery.asp
Back to top
View user's profile Send private message
Akede
Smarty n00b


Joined: 28 Jan 2016
Posts: 3

PostPosted: Fri Jan 29, 2016 11:29 am    Post subject: Reply with quote

Thanks to AnrDaemon,

I understand that too much logic code may not be good at all, but is it still possible to handle my problem with smarty?

Thanks in advance.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Fri Jan 29, 2016 3:19 pm    Post subject: Reply with quote

Smarty is running on SERVER, which know nothing of the CLIENT dismensions and stuff.
Either supply client with necessary information how to render your layout, or use client-side scripting (i.e. JS) to aid your task.
Back to top
View user's profile Send private message
Akede
Smarty n00b


Joined: 28 Jan 2016
Posts: 3

PostPosted: Fri Jan 29, 2016 5:34 pm    Post subject: Reply with quote

Got it - thank you!
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