|
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 |
Akede Smarty n00b
Joined: 28 Jan 2016 Posts: 3
|
Posted: Thu Jan 28, 2016 7:00 pm Post subject: SOLVED - Use viewport or media query with smarty |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
|
Back to top |
|
Akede Smarty n00b
Joined: 28 Jan 2016 Posts: 3
|
Posted: Fri Jan 29, 2016 11:29 am Post subject: |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Fri Jan 29, 2016 3:19 pm Post subject: |
|
|
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 |
|
Akede Smarty n00b
Joined: 28 Jan 2016 Posts: 3
|
Posted: Fri Jan 29, 2016 5:34 pm Post subject: |
|
|
Got it - thank you! |
|
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
|