The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> One Navigation across 100 pages
vinay111
post Aug 25 2013, 09:51 AM
Post #1





Group: Members
Posts: 8
Joined: 10-September 10
Member No.: 12,700



I have a website in which I have more than 50 pages. Unfortunately, if I place a new category in it I have to manually edit all the 50 pages by cutting and pasting. Is there a way through which I can automatically edit all the 50 pages. I am aware there is a PHP include command, but I have been told that I have to change the page extension from index.html to index.php, which I don't want. Request share your views please.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Aug 25 2013, 10:01 AM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



No, you don't have to change the extension. You can make the server parse HTML files for PHP instead. Same if you choose to use SSI (server side includes). Servers are usually configured to parse files with the .shtml extension for SSI, but can be configured to parse html files as well. You do this through your .htaccess file.

There is no other way to accomplish what you want. Well, there is frames, but don't even think of going there. Or you could process the files on your own computer. Basically advanced Find & Replace works. But in the long run, doing it server side is the least work.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
vinay111
post Aug 25 2013, 10:17 AM
Post #3





Group: Members
Posts: 8
Joined: 10-September 10
Member No.: 12,700



I shall be highly obliged if you show me the correct way to do it. For example, I am aware that I have to create a separate file for navigation like:

<div>
<ul>
<li><a href="home.html">Home Page</a></li> <li><a href="gallery.html">Gallery Page</a></li> <li><a href="about.html">About Page</a></li> <li><a href="contact.html">Contact Page</a></li>
</ul>
</div>

Secondly, I have been told the following:

Required Filetypes:

By default, servers will only parse PHP code inside files with the .php extension. Therefore, you must change the extension of any files you want to use includes in to .php (e.g. index.html becomes index.php). Although your main file must have a .php extension, you can include files with extensions such as .html, .txt, .inc, other .php files, and more.

Syntax

PHP Code: <?php include( 'file_to_include.html' ); ?>

After reading the above I am wondering/confused that whether all my files have a .PHP extension or they will remain .html? Or server will automatically do the job, and all my files will remain as it is?

Thanks for your time.

This post has been edited by vinay111: Aug 25 2013, 10:18 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Aug 25 2013, 11:48 AM
Post #4


.
********

Group: WDG Moderators
Posts: 9,656
Joined: 10-August 06
Member No.: 7



Something like this in a .htaccess file should work with most web servers that use .htaccess directives (such as Apache, don't know about IIS):

CODE
AddType application/x-httpd-php .php .html

The above makes web pages with the listed extensions (you can add more if you want) use PHP.

The included files can have any extension you want, you don't need to configure anything for them.

QUOTE
Secondly, I have been told the following:

That only applies if you don't use the above .htaccess directive.

QUOTE
After reading the above I am wondering/confused that whether all my files have a .PHP extension or they will remain .html?

They will remain ".html". smile.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
vinay111
post Aug 26 2013, 03:25 AM
Post #5





Group: Members
Posts: 8
Joined: 10-September 10
Member No.: 12,700



Thanks for your time Christian.

That means I have to create .htaccess file (I wish to inform you that all my site is in .html only) and include the line in it:
AddType application/x-httpd-php .php .html , and upload it on the server.

After this I have to follow the steps like I mentioned earlier like creating separate navigation file, and including the line like "PHP Code: <?php include( 'file_to_include.html' ); ?>"

Am I correct?

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Aug 26 2013, 06:46 AM
Post #6


.
********

Group: WDG Moderators
Posts: 9,656
Joined: 10-August 06
Member No.: 7



Yes that's correct.

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Aug 26 2013, 07:26 AM
Post #7


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



A word of warning though. If you make a mistake, like a simple typo, in your .htaccess file your site will stop to work. That's no biggie, just delete the erroneous .htaccess file or correct it. But, servers are often configured to hide dot files and it isn't certain you can see the file with your FTP program. There are ways to change that too, but to play safe, upload an empty .htaccess file and make sure you see it there on the server. Holler if you don't and we'll help you.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
vinay111
post Aug 26 2013, 11:12 AM
Post #8





Group: Members
Posts: 8
Joined: 10-September 10
Member No.: 12,700



QUOTE(pandy @ Aug 26 2013, 07:26 AM) *

A word of warning though. If you make a mistake, like a simple typo, in your .htaccess file your site will stop to work. That's no biggie, just delete the erroneous .htaccess file or correct it. But, servers are often configured to hide dot files and it isn't certain you can see the file with your FTP program. There are ways to change that too, but to play safe, upload an empty .htaccess file and make sure you see it there on the server. Holler if you don't and we'll help you.


Yes Pandy, I have uploaded the .htaccess file and can see it too. Shall I write the words "AddType application/x-httpd-php .php .html", as has been mentioned.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
vinay111
post Aug 26 2013, 11:59 AM
Post #9





Group: Members
Posts: 8
Joined: 10-September 10
Member No.: 12,700



QUOTE(vinay111 @ Aug 26 2013, 11:12 AM) *

QUOTE(pandy @ Aug 26 2013, 07:26 AM) *

A word of warning though. If you make a mistake, like a simple typo, in your .htaccess file your site will stop to work. That's no biggie, just delete the erroneous .htaccess file or correct it. But, servers are often configured to hide dot files and it isn't certain you can see the file with your FTP program. There are ways to change that too, but to play safe, upload an empty .htaccess file and make sure you see it there on the server. Holler if you don't and we'll help you.


Yes Pandy, I have uploaded the .htaccess file and can see it too. Shall I write the words "AddType application/x-httpd-php .php .html", as has been mentioned.


That means I have to create .htaccess file (I wish to inform you that all my site is in .html only) and include the line in it:
AddType application/x-httpd-php .php .html , and upload it on the server.

After this I have to follow the steps like I mentioned earlier like creating separate navigation file, and including the line like "PHP Code: <?php include( 'file_to_include.html' ); ?>"


I have taken all the steps, unfortunately, the navigation is not working. I have included the following in the navigation.html file

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Navigation Top</title>
<link href="stylesheet.css" type="text/css" rel="stylesheet" />
</head>

<body>
<div class="navigationtop">
<ul>
<li><a href="">Home</a></li>
<li><a href="">About Us</a></li>
<li><a href="">Contact Us</a></li>
</ul>
</div>
</body>
</html>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Aug 26 2013, 12:18 PM
Post #10


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Yup, you've got it. And remember, if things go wrong, just delete the .htaccess file and start over.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
vinay111
post Aug 26 2013, 12:35 PM
Post #11





Group: Members
Posts: 8
Joined: 10-September 10
Member No.: 12,700



I have tried the above steps and put the code
QUOTE
<?php include( 'file_to_include.html' ); ?>
in a trial html file and uploaded on the server, unfortunately the navigation is not showing up.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Aug 26 2013, 03:22 PM
Post #12


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Does it work if you use it in a file in the same directory but with the extension .php?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
vinay111
post Aug 26 2013, 10:36 PM
Post #13





Group: Members
Posts: 8
Joined: 10-September 10
Member No.: 12,700



QUOTE(pandy @ Aug 26 2013, 03:22 PM) *

Does it work if you use it in a file in the same directory but with the extension .php?

Yes, I can see the navigation/header extension with .php

But two of the divs on the page get distorted, which were looking fine in the .html
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Aug 27 2013, 04:10 PM
Post #14


.
********

Group: WDG Moderators
Posts: 9,656
Joined: 10-August 06
Member No.: 7



QUOTE(vinay111 @ Aug 26 2013, 06:59 PM) *

That means I have to create .htaccess file (I wish to inform you that all my site is in .html only) and include the line in it:
AddType application/x-httpd-php .php .html , and upload it on the server.

Did you put it in the web root directory (same as your index.html file)? .htaccess files only affect their own directory and its child directories. Does your server run Apache?

If both answers to these questions are "yes" perhaps your web host support could help further.

QUOTE

I have included the following in the navigation.html file

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Navigation Top</title>
<link href="stylesheet.css" type="text/css" rel="stylesheet" />
</head>

<body>
<div class="navigationtop">
<ul>
<li><a href="">Home</a></li>
<li><a href="">About Us</a></li>
<li><a href="">Contact Us</a></li>
</ul>
</div>
</body>
</html>

You should only include the actual nav menu's HTML:

CODE
<div class="navigationtop">
<ul>
<li><a href="">Home</a></li>
<li><a href="">About Us</a></li>
<li><a href="">Contact Us</a></li>
</ul>
</div>

(unlike a framed page, an inclusion file is not a complete HTML document, it's just a code snippet).
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 24th April 2024 - 09:03 AM