|
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 |
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Thu May 05, 2016 10:52 pm Post subject: |
|
|
Presentation logic may consider converting or filtering certain data structures.
I.e. I have a menu structure pulled from a database, with multiple fields marked as "authorized only" or other indicative flags. I only need to display a few due to the current pass being done with "ANON_ACCESS" flag raised. Presentation logic would adhere to the flag and filter out any data that is not available to the anonimous visitor.
This way, I will not need to make multiple database queries for different flags, which means, the query results would be almost always in the DB server cache even if I'm not using page cache.
This will also reduce maintenance times. When menu structure or accessibility changes, I either don't need to change query, or need to only change it in one place. |
|
Back to top |
|
macblack77 Smarty Rookie
Joined: 29 Mar 2016 Posts: 13
|
Posted: Fri May 06, 2016 11:54 am Post subject: |
|
|
Thank you, that example really helps. |
|
Back to top |
|
elpmis Smarty Elite
Joined: 07 Jun 2007 Posts: 321
|
Posted: Sat May 07, 2016 6:23 am Post subject: |
|
|
macblack77 wrote: | I appear to loose control over presentation (e.g. making one word in a paragraph bold or italic). |
No.
You can use the assigned results as formatting trigger too .
Code: | <h3 class="{$subtitle}">{$subtitle}</h3> |
Now you can define some CSS depending on $subtitle ... or the longer way (in cause of empty spaces inside the header)
Code: | <h3 class="{if $subtitle == 'NEW LISTING'}somestyle{elseif $subtitle == 'REGISTRATION'}someotherstyle{else}defaultstyle{/if}">{$subtitle}</h3> |
|
|
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
|