-
Notifications
You must be signed in to change notification settings - Fork 7
Are there conditional tags?
deseven edited this page Mar 21, 2017
·
4 revisions
Vodka doesn't have traditional conditional tags. It's approach is to simulate conditional tags via usage of replaceVar() method and custom PHP logic.
Thus in your index.php
besides simple assignment:
$lorem = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
$vodka->replaceVar('LOREM', $lorem);
You may also use any conditions:
$body_class = '';
if($page['name'] == 'second') { $body_class = ' class="page-second"'; }
$vodka->replaceVar('BODYCLASS', $body_class);
and putting HTML into strings:
$intro_text = '';
if($page['name'] == 'second') { $intro_text = '<div class="intro-text"><h2>Intro</h2><p>Intro text...</p></div>'; }
$vodka->replaceVar('INTROTEXT', $intro_text);
Replaced vars then used in your templates and pages.