OllieMackJames Posted February 10, 2019 Share Posted February 10, 2019 In my template I want to exclude some html based on a field being checked. The field landingpage is a checkbox field, and if it is checked I want to exclude the html below from showing up, how can I do that? Thanks! <?php if $page->landingpage=1; //If the checkbox field landingpage is checked I want to exclude the following html code: <!-- Top Navigation Bar --> <div class="site-nav"> <div id="navcontrol" class="logobanner centered original-nav"> <label for="navtoggle" class="navtoggle"><img src="/site/templates/img/logo.png" width="196" alt="logo" title="Menu Toggle" alt="Menu Toggle"><span class='menu-toggle-text'><?=$menu_title?></span></label> </div> <input type="checkbox" id="navtoggle"/> <div class="top"> <nav class="original-nav"> <div id="logoline" class="logobanner logobanner-original centered"> <a href='/'><img src="/site/templates/img/logo.png" width="<?=intval($config->navLogoWidth)?>" alt="logo" style="max-width:<?=intval($config->navLogoWidth)?>px"></a> </div> <ul class="menu"> <!--?= renderNav($page); ?--> </ul> </nav> </div> </div> Link to comment Share on other sites More sharing options...
dragan Posted February 10, 2019 Share Posted February 10, 2019 (edited) if $page->landingpage=0 ? see below... Edited February 10, 2019 by dragan facepalm moment Link to comment Share on other sites More sharing options...
kongondo Posted February 10, 2019 Share Posted February 10, 2019 1 minute ago, dragan said: if $page->landingpage=0 ? Admittedly I don't use this PHP syntax but aren't we missing a second = ? Otherwise we are assigning instead of comparing :-). Link to comment Share on other sites More sharing options...
dragan Posted February 10, 2019 Share Posted February 10, 2019 hehe, sorry, it's a lazy Sunday here... of course you'd use == or <1. Maybe you can even use if(!$page->field) but I'm too lazy to test Link to comment Share on other sites More sharing options...
OllieMackJames Posted February 10, 2019 Author Share Posted February 10, 2019 @dragan thanks, but I don't understand yet, I tried the following but then the front end throws errors. <?php if ($page->landingpage !== 1) echo ([ <!-- Top Navigation Bar --> <div class="site-nav"> <div id="navcontrol" class="logobanner centered original-nav"> <label for="navtoggle" class="navtoggle"><img src="/site/templates/img/logo.png" width="196" alt="logo" title="Menu Toggle" alt="Menu Toggle"><span class='menu-toggle-text'><?=$menu_title?></span></label> </div> <input type="checkbox" id="navtoggle"/> <div class="top"> <nav class="original-nav"> <div id="logoline" class="logobanner logobanner-original centered"> <a href='/'><img src="/site/templates/img/logo.png" width="<?=intval($config->navLogoWidth)?>" alt="logo" style="max-width:<?=intval($config->navLogoWidth)?>px"></a> </div> <ul class="menu"> <!--?= renderNav($page); ?--> </ul> </nav> </div> </div> ]); Link to comment Share on other sites More sharing options...
OllieMackJames Posted February 10, 2019 Author Share Posted February 10, 2019 OK, solved, I copied the html to a file called nav.inc, then added this code to the template: <?php if ($page->landingpage !== 1) include ('nav.inc'); ?> That did the trick. Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now