Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

ursan ciprian
ursan ciprian
5,551 Points

hiding html elements using php

Hi. I am being asked to hide some html elements, the sidebar, depending on the page: not found page, login and register. i only managed to hide them in the not found page. Can someone help me?

My code so far looks like this: index.php

<?php

require_once 'application/init.php';

$TEMPLATE_VARS = array( 'pageNotFound' => false );

$page = isset($_GET['page']) ? $_GET['page'] : 'home';

$pagePath = APP_PATH . 'pages/' . $page . '.php';

if (file_exists($pagePath)) { require_once $pagePath; } else { $TEMPLATE_VARS['templatePath'] = APP_PATH . 'templates/components/not_found.php'; $TEMPLATE_VARS['pageNotFound'] = true; }

require_once APP_PATH . 'templates/components/main.php';

main.php

<body>
    <div class="wrap">
       <?php require_once 'header.php'; ?>

       <div class="content">
           <main>
              <?php require_once $TEMPLATE_VARS['templatePath']; ?>
           </main>

           <?php 
           if(!$TEMPLATE_VARS['pageNotFound']) {
           require_once 'aside.php'; 
           }
           ?>

           <div class="clear"></div>
       </div>
   </div>

    <?php require_once 'footer.php';?>
</body>

THx