Mr.Canuck Posted March 31, 2010 Share Posted March 31, 2010 Hey everyone. I do NOT want the following code to be executed on a page of mine called "intro". I DO however, want the following code to be executed on all other pages on the site. I am a PHP novice. How would I write a proper if else statement to say " IF($cpage=="intro") Then DO NOT execute the following code and... ELSE (execute the following code) ? Here is the "following code" that I have been talking about: <div id="rightside"> <?php if($this->showCart()) $this->cartPnl->Render(); ?> <div style="clear: both;"> <?php if($this->showSideBar()) $this->sidePnl->Render(); ?> </div> </div> Quote Link to comment https://forums.phpfreaks.com/topic/197056-if-else-statement/ Share on other sites More sharing options...
zeodragonzord Posted March 31, 2010 Share Posted March 31, 2010 You're probably looking for something like.. if($cpage != "intro")//if this is not intro page { //show this } Quote Link to comment https://forums.phpfreaks.com/topic/197056-if-else-statement/#findComment-1034435 Share on other sites More sharing options...
Mr.Canuck Posted March 31, 2010 Author Share Posted March 31, 2010 Thank you! Much appreciated!! Quote Link to comment https://forums.phpfreaks.com/topic/197056-if-else-statement/#findComment-1034437 Share on other sites More sharing options...
mikesta707 Posted March 31, 2010 Share Posted March 31, 2010 that was weird. whole post wasn't sent. nevermind Quote Link to comment https://forums.phpfreaks.com/topic/197056-if-else-statement/#findComment-1034441 Share on other sites More sharing options...
Mr.Canuck Posted March 31, 2010 Author Share Posted March 31, 2010 I did that, but now I'm getting this error: "Parse error: syntax error, unexpected $end in /home/scrapbk/store/templates/ga_active/index.tpl.php on line 250" Here is the full code below. I appreciate the help: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?= _xls_get_conf('LANG_CODE' , 'en') ?>" dir="ltr"> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?= _xls_get_conf('CHARSET' , 'utf-8') ?>" /> <?php $meta_desc = _xls_stack_pop('xls_meta_desc'); if($meta_desc){ ?> <meta name="description" content="<?= $meta_desc; ?>"> <?php } ?><?php $meta_keywords = _xls_stack_pop('xls_meta_keywords'); if($meta_keywords){ ?> <meta name="keywords" content="<?= $meta_keywords; ?>"> <?php } ?><?php $redirect = _xls_stack_pop('xls_meta_redirect'); if($redirect && isset($redirect['url']) && isset($redirect['delay'])){ ?> <meta http-equiv="refresh" content="<?= $redirect['delay']; ?>;URL=<?= $redirect['url']; ?>"/> <?php } ?> <meta name="Author" content="<?= _xls_get_conf('STORE_NAME' , 'Web Store.') ?>" /> <meta name="Copyright" content="<?= _xls_get_conf('COPYRIGHT_MSG' , 'Xsilva Inc.') ?>" /> <meta name="Generator" content="Xilva Lightspeed Webstore <?= _xls_version(); ?>" /> <meta http-equiv="imagetoolbar" content="false" /> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> <base href="<?= _xls_site_dir(); ?>/"/> <?php global $strPageTitle; ?> <?php if (isset($strPageTitle)): ?> <title><?= _xls_get_conf('STORE_NAME', _sp('Shopping cart')); ?> : <?php _p($strPageTitle); ?></title> <?php endif; ?> <link rel="Shortcut Icon" href="favicon.ico" type="image/x-icon" /> <link rel="stylesheet" type="text/css" href="assets/css/reset.css" /> <link rel="stylesheet" type="text/css" href="<?= templateNamed('css') ; ?>/webstore.css" /> <link rel="stylesheet" type="text/css" href="assets/css/pushup.css" /> <!--[if IE]> <script src="assets/js/ie.js" type="text/javascript"></script> <![endif]--> <!--[if IE 7]> <link rel="stylesheet" type="text/css" href="<?= templateNamed('css') ; ?>/ie7.css" /> <![endif]--> <!--[if lt IE 7]> <link rel="stylesheet" type="text/css" href="<?= templateNamed('css') ; ?>/ie6.css" /> <![endif]--> <link rel="stylesheet" type="text/css" href="assets/css/search.css" id="searchcss" /> <link rel="stylesheet" type="text/css" href="assets/css/dummy.css" id="dummy_css" /> <link rel="stylesheet" type="text/css" href="assets/css/datepicker.css" /> <script type="text/javascript"> var XLSTemplate = "<?= templateNamed(''); ?>"; </script> </head> <script type="text/javascript" src="assets/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="assets/js/webstore.js"></script> <?php $this->RenderBegin(); ?> <script type="text/javascript" src="assets/js/pushup.js"></script> <script type="text/javascript"> $(function() { $("#datepicker").datepicker(); }); </script> <!--<![endif]--> <script type="text/javascript"> //<![CDATA[ window.onload = function () { applesearch.init(); } //]]> </script> <div id="maincontain"> <?php $this->dxLogin->Render(); ?> <div id="container"> <div id="header"> <div id="login" class="rounded {5px bottom transparent}"> <?php if(!$this->isLoggedIn()): ?> <div class="text"> <div class="left" style="margin: 0 55px 0 0;"><?php _p("Welcome!"); ?></div> <div class="right"><a href="#" <?php $this->pxyLoginLogout->RenderAsEvents() ?>class="loginbox"><?php _p("Login"); ?></a> | <a href="index.php?xlspg=customer_register"><?php _p("Register"); ?></a></div> </div> <?php else: ?> <div class="text"><div style="margin: 0 105px 0 0; display: block; float: left;"><a href="index.php?xlspg=myaccount"><?= _p("My Account"); ?></a></div> <?php $this->lblLogout->Render(); ?></div> <?php endif; ?> </div> <a href="index.php"> <img src="<?php $img = _xls_get_conf('HEADER_IMAGE' , false ); if(!$img) $img = templateNamed('images') . '/webstore_installation.png'; else{ $img = _xls_get_url_resource($img); } echo $img; ?>" /> </a> </div> <div id="body"> <div id="content" class="rounded {5px top-right bottom transparent}"> <div id="nav" class="rounded {5px top transparent}"> <ul> <li id="aboutUs"><a href="<?= _xls_custom_page_url('about') ?>"><?php _p('About Us'); ?></a></li> <li id="products"><a href="<?= _xls_custom_page_url('products') ?>"><?php _p('Products'); ?></a></li> <li id="promotions"><a href="<?= _xls_custom_page_url('promo') ?>"><?php _p('Promotions'); ?></a></li> <li id="newsletter"><a href="<?= _xls_custom_page_url('newsletter') ?>"><?php _p('Newsletter'); ?></a></li> <li id="contact"><a href="index.php?xlspg=contact_us"><?php _p('Contact'); ?></a></li> <li id="search"><?php $this->searchPnl->Render(); ?></li> </ul> </div> <?php $this->crumbTrail->Render(); ?> </div> <noscript> <h1> <?php _p('This store requires you to have a Java-Script enabled web browser. Please visit ') ; echo '<a href="www.firefox.com" target="_blank">Firefox</a>' ; _p(' to download to latest version.'); ?> </h1> </noscript> <?php $this->mainPnl->Render(); ?> </div> if(!$cpage == "intro"){ ?> <div id="rightside"> <?php if($this->showCart()) $this->cartPnl->Render(); ?> <div style="clear: both;"> <?php if($this->showSideBar()) $this->sidePnl->Render(); ?> </div> </div> <?php } </div> <div id="footer" class="rounded {5px transparent}"> <div class="left">© <?php _p('Copyright'); ?> <?= date("Y"); ?> <?= _xls_get_conf('STORE_NAME' , 'Your Store') ?>. <?php _p('All Rights Reserved'); ?>.</div> <div class="right"> <a href="<?= _xls_custom_page_url('about') ?>"><?php _p('About Us'); ?></a> | <a href="<?= _xls_custom_page_url('tc') ?>"><?php _p('Terms & Conditions'); ?></a> | <a href="<?= _xls_custom_page_url('privacy') ?>"><?php _p('Privacy Policy'); ?></a> | <a href="index.php?xlspg=sitemap"><?php _p('Sitemap'); ?></a> </div> </div> </div> <!-- place google analytics here --> <?php $this->dummy_drag_drop->Render(); ?> <?php $this->RenderEnd(); ?> <?php if(QApplication::$Database[1]->EnableProfiling) echo QApplication::$Database[1]->OutputProfiling(); ?> <script type="text/javascript"> <?php if($this->blnGetScreenRes): ?> $.post(document.forms[0].action , { store_screen: "true", width: screen.width , height: screen.height } ); <?php endif; ?> //done </script> <?php if(_xls_get_conf('DEBUG_TEMPLATE' , false)): ?> <?php $files = array(); ?> <!-- Template files used <?php while($filename = _xls_stack_pop('template_used')): ?> <?php $files[] = $filename; ?><?= $filename; ?> <?php endwhile; ?> --> <?php _xls_log(sprintf(_sp("Template files used %s") , implode(", " , $files))); ?> <?php endif; ?> <?php if($expires = _xls_page_session_expiry_duration()): ?> <script type="text/javascript"> <?php // in case of session expiry, reload the page so we don't get ajax/javascript errors. // the added 5 seconds will ensure that user will be logged out due to inactivity ?> window.setTimeout("document.location.href='<?= _xls_site_dir() ?>/index.php'" , <?= $expires ?> * 1000 + 5000 ); </script> <?php endif; ?> </div> </html> Quote Link to comment https://forums.phpfreaks.com/topic/197056-if-else-statement/#findComment-1034446 Share on other sites More sharing options...
DavidAM Posted March 31, 2010 Share Posted March 31, 2010 You are missing the PHP opening tag just before the if statement. Quote Link to comment https://forums.phpfreaks.com/topic/197056-if-else-statement/#findComment-1034505 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.