Jump to content

Creating own template for website


loJic

Recommended Posts

Newbie here! Not sure if this is basic 101 html or something too far advanced. I'm looking to create a template for my site. My site has about 7 pages thus far, looking to create tons more, and every time I need to make an adjustment to the navigation bar I have to go in to each page and edit. I'm only assuming that there is an easier way to have it set to where when I edit it in the main page that it is universal to the whole site. Same goes for when changing the header/logo or the footer etc.... Here is my site: www.laprepsoccer.net This is the first site i've ever created and think i may be in over my head with a lot of this stuff. I'm hoping that there is a simple answer for this question. I already have each paged linked to a css file so when i make a change there it does so throughout the site. So again, i'm assuming this is doable. Hopefully a simple solution. Do i need to post any code?

Edited by loJic
Link to comment
Share on other sites

Best way is a little simple PHP. This was what introduced me to php, and if your going to get heavy into coding learn PHP and js, etc.Create a HTML file with your nav bar, and in place of your navbar in the pages put <?php include"nav.html";?> all your pages must now be labeled as .phpGood luck

  • Like 1
Link to comment
Share on other sites

Best way is a little simple PHP. This was what introduced me to php, and if your going to get heavy into coding learn PHP and js, etc. Create a HTML file with your nav bar, and in place of your navbar in the pages put <?php include"nav.html";?> all your pages must now be labeled as .php Good luck
Thanks! So all of my pages will have to be changed from html to php or were you referring to just the navbar.php page?
Link to comment
Share on other sites

IF you use php code <?php include"nav.html";?> the page you are inserted into needs to be php, the navigation code if not using php code, but just html, can be just be *.htm or *.html. Note only the html code for navigation is required, not <html><head><body> etc, or links to css style sheetsheet, javacript etc, as these should be placed within the page it is being included in.

Link to comment
Share on other sites

IF you use php code <?php include"nav.html";?> the page you are inserted into needs to be php, the navigation code if not using php code, but just html, can be just be *.htm or *.html. Note only the html code for navigation is required, not <html><head><body> etc, or links to css style sheetsheet, javacript etc, as these should be placed within the page it is being included in.
Again just a little confused. So i'm creating a php file to insert my navigation code in to. When I link that code in to my other html pages do they need to be switched to php? That's what's confusing me. Edited by loJic
Link to comment
Share on other sites

This IS php code <?php include"nav.html";?> php can consist of html code as well as php, but php must begin with <?php and end with ?> but ANY php code used within a page MUST have extension .php for the filename example nav 1)This is just html code, it reference php for links, but it is still html, and can be given filename of nav.html

<ul id="nav"> <li><a href="index.php">Home</a></li><li><a href="aboutus.php">About Us</a></li><li><a href="contactus.php">Contact Us</a></li></ul>

(insert into main document pages with <?php include"nav.html";?>) 2)This code uses php to display opening and closing html UL tags therefore must have filename of nav.php

<?php echo '<ul id="nav">';?><li><a href="index.php">Home</a></li><li><a href="aboutus.php">About Us</a></li><li><a href="contactus.php">Contact Us</a></li><?phpecho '</ul>';?>

(insert into main document pages with <?php include"nav.php";?>) This is all that is required to insert or include the navigation code using php into main document pages. Now because it uses php to include the navigation in both cases (<?php include"nav.php";?> or <?php include"nav.html";?>), the pages MUST end with extension .php as in index.php, aboutus.php, and contactus.php, and whereever you wish the navigation to appear you place <?php include"nav.php";?> or <?php include"nav.html";?> (depending how you choose show the navigation option (1) or (2)) at that location, and in both cases, what will appear is

<ul id="nav"> <li><a href="index.php">Home</a></li><li><a href="aboutus.php">About Us</a></li><li><a href="contactus.php">Contact Us</a></li></ul>

  • Like 1
Link to comment
Share on other sites

Again just a little confused. So i'm creating a php file to insert my navigation code in to. When I link that code in to my other html pages do they need to be switched to php? That's what's confusing me.
A PHP file is just an HTML file with a different file extension, and with snippet(s) of PHP code included. In this case, the PHP code you're using is:
<?php include"nav.html";?>

So the pages that you want to insert the navbar into need to be .php, because they're the pages with the PHP code. The file it is you're inserting can be PHP if you need it to be, but in this case it's just static HTML so you can leave the extension as .html (see in the code above it's nav.html, not nav.php). Hope this makes sense.

2)This code uses php to display opening and closing html UL tags therefore must have filename of nav.php
<?php  echo '<ul id="nav">';?><li><a href="index.php">Home</a></li><li><a href="aboutus.php">About Us</a></li><li><a href="contactus.php">Contact Us</a></li><?phpecho '</ul>';?>

Why would you need to write the tags using PHP? Isn't it just static HTML? Edited by Charles @ CodeConquest.com
Link to comment
Share on other sites

Thank you repeating basically everything i just said i really really enjoying reading the same answer, again and again thanks for that, it really made my day.

Why would you need to write the tags using PHP? Isn't it just static HTML?
Well i didn't want write whole template php class code where, it would read menu and submenu links from database, and reproduce these in html unordered list code, So since i just required a simply example to illustrate the use of php code being used, i thought i would just echo out the start and end tags of ul instead, since the OP is the only person who would know if he is using PHP or NOT, ok we happy now!
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...