• There is an important update regarding account security and 2FA. Please click here for more information.
  • ❤️ It's that time of the year again - Happy Valentine's Day! Luvdisc is back to help spread the luv again. Interested in sending a message of appreciation to some special users on the site, and earning a brand-new badge in the process? Then click here for more information! ❤️
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.
  • Imgur has blocked certain regions from viewing any images uploaded to their site. If you use Imgur, please consider replacing any image links/embeds you may have on PokéCommunity so everyone can see your images. Click here to learn more.

NavBar PHP Includes

Trikip

Can you Handel this?
  • 1,643
    Posts
    21
    Years
    I've been working on my website, and it's made me realize that the navbar PHP includes code would be a BIG help. Can someone please show me how to set it up and how it works?

    EDIT: This belongs in resources, sorry, please move this.
     
    Last edited:
    Create one navbar and call it left.php. Do the same with the right. This would be index.php:
    PHP:
    <?php include "left.php"; ?>
    content here
    <?php include "right.php"; ?>
     
    I kinda don't really know what you're talking about...
     
    ok where you normally have your left navigation put <?php include "left.php"; ?> code in create a page called left.php (i think it could also be html or txt) and in that page have your navigation
     
    Ok, so instead of putting my left nav at all, I would only put <?php include "left.php"; ?> and just make left.php with the left nav in it?

    EDIT: I'm pretty sure I get this now, it's a lot easier than I thought lol.

    EDIT 2: Ok, what do I do after that?
     
    Last edited:
    heres how i do it:

    PHP:
    <!-- Main -->
    <div id="main">
    <table width="770" border="0" cellspacing="0" cellpadding="2" align="center">
      <tr>
        <td width="130" valign="top" align="left"><!-- Start Left Banner -->
    		<?php include ('left_nav.inc'); ?>
    		<?php include ('left_ads.inc'); ?>
    	<!-- End Left Banner -->
    	</td>
            <td width="520" valign="top">
    		<!-- Start Main Content
    <php include ("ads.txt"); ?><br /> -->
    <?php
    if (!$id) {
    $id = "main";
    $include = $id . ".html";
    }
    else {
    $include = $id . ".html";
    }
    if (is_file($include) == "1") {
            include $include;
    }
    else {
    include "404.html";
    }
    ?>
    <div align="center"><hr width="80%">
    <?php include ('topsites.inc'); ?>
      <!-- End Main Content -->
        </td>
        <td width="120" valign="top"><!-- Begin Right Banner -->
    		<?php include ('pokedex.inc'); ?>
    		<br />
    		<?php include ('right_nav.inc'); ?>
    		<?php include ('whats_on.inc'); ?>		
    		<?php include ('right_ads.inc'); ?>
      <!-- End Right Banner -->
    	  </td>
      </tr>
    </table></div>
     
    Yeah, someone tried to teach it to me that way, but I got confused lol.
     
    As I've tried to tell you many a time, don't include the menus, include the content :/

    have your content files in pages/ (or rename to watever)
    and called watever.html, watev4.html, whatever.html etc.
    Code:
    <? include("pages/" . $spc . ".html"); ?>
    There's some way to make sure the file exists but I've forgotten the code.

    Oooh yeah, make your links like this

    Code:
    <a href="?spc=watever">Watever</a><br>  // this will include pages/watever.html
    <a href="?spc=watev4">Wateva</a><br>  // this will include pages/watev4.html
    <a href="?spc=wateva">Watev4</a><br> // this will include pages/wateva.html
     
    Okay -- Goto Your site..Open the Source..Copy it Fully & paste and In a Notepad or HTML Editor. Del all the Content and have only the Stuff you will have as COmmon on all Pages --> Layouts, Links,etc.
    Then Follow what Kip-Kip Tells in the "PHP/CSS Help Thread"
     
    PD Wooper said:
    As I've tried to tell you many a time, don't include the menus, include the content :/

    have your content files in pages/ (or rename to watever)
    and called watever.html, watev4.html, whatever.html etc.
    Code:
    <? include("pages/" . $spc . ".html"); ?>
    There's some way to make sure the file exists but I've forgotten the code.

    Oooh yeah, make your links like this

    Code:
    <a href="?spc=watever">Watever</a><br>  // this will include pages/watever.html
    <a href="?spc=watev4">Wateva</a><br>  // this will include pages/watev4.html
    <a href="?spc=wateva">Watev4</a><br> // this will include pages/wateva.html


    After thinking for about five minutes, I've finally realized what you mean. XD Thanks a lot, I will try that.

    EDIT: Ok, now I'm confused. On my index page, I'm getting a "Warning" thing and it said the page doesn't exist. Then when I go to the page I was trying to include (my staff page), it shows the content of my index page, then it shows the content of the staff page.
     
    Last edited:
    *screams* Something like this is gonna confuse webmasters. Is there a tute in the Tech Institute? If not, I'll write one...
     
    I'm pretty sure there isn't a tutorial, if you right one please let me know.
     
    Yeah, I put it on the index page like you told me to.
     
    Oh...uhm..it should work...make sure you dont have the whole layout on your content files.
     
    Nope, I don't. The code I put was:

    <? include("pages/" . $spc . "staff.html"); ?>

    And the link code I put was:

    <a href="?spc=staff">Staff</a>

    Oh lol, I was supposed to put this right?

    <a href="https://www.thestorageunit.com/slateport/?spc=staff">Staff</a>
     
    Last edited:
    Back
    Top