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

Accessing class constants
Goto page Previous  1, 2
 
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
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu May 05, 2016 10:52 pm    Post subject: Reply with quote

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


Joined: 29 Mar 2016
Posts: 13

PostPosted: Fri May 06, 2016 11:54 am    Post subject: Reply with quote

Thank you, that example really helps.
Back to top
View user's profile Send private message
elpmis
Smarty Elite


Joined: 07 Jun 2007
Posts: 321

PostPosted: Sat May 07, 2016 6:23 am    Post subject: Reply with quote

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 Wink.

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
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
Goto page Previous  1, 2
Page 2 of 2

 
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