Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
add same text link on all of my html pages
Old 08-25-2004, 03:23 PM add same text link on all of my html pages
Webguy's Avatar
Novice Talker

Posts: 14
Location: canada
Trades: 0
Hey everyone.

I am very new to php, but I am starting to get the hang of it. What I need to do is have all the links on my entire directory change just by changing one file. For example, if I wanted to changed even one link on all of my pages, I would manually have to go to each HTML page and do it one by one.

A little while ago I found the code do automatically updat all of your pages for you buy just changing the one txt file. help!

Thanks in advance for you help.
Webguy is offline
Reply With Quote
View Public Profile Visit Webguy's homepage!
 
 
Register now for full access!
Old 08-25-2004, 03:33 PM
DevelopedWeb's Avatar
Webmaster Talker

Posts: 610
Location: USA
Trades: 0
Alright, the best and easiest way to do this is just to use a general "template" for your website.

If all of your pages have the same layout, chances are they have a great portion of the same code as well. What you can do is cut and paste the code that remains constant across all pages to new files, and include these files in your new PHP code by using the require function.

Let's say your HTML code looked like the following:

<HTML>
<TITLE>Title Here</TITLE>
<STYLE type="text/css">
<!--
BODY {
...
}
H1 {
...
}
</STYLE>
<SCRIPT language="Javascript" src="myjslibrary.js">
</HEAD>
<BODY>
<TABLE>
<TR>
<TD>
<UL>
<LI><a href="link.html">Link
<LI><a href="link.html">Link
<LI><a href="link.html">Link
<LI><a href="link.html">Link
<LI><a href="link.html">Link
<LI><a href="link.html">Link
</UL>
</TD>
<TD>
Content goes here!
</TD>
</TR>
</TABLE>
</BODY>
</HTML>

What you can do is save the part before the content and after the content as seperate files, as follows:

------------------------

<STYLE type="text/css">
<!--
BODY {
...
}
H1 {
...
}
</STYLE>
<SCRIPT language="Javascript" src="myjslibrary.js">

------------------------

That goes in the head section, so call it something like "head.inc.php".

Then, the beginning of the body ("top.inc.php", perhaps?)--

------------------------

<TABLE>
<TR>
<TD>
<UL>
<LI><a href="link.html">Link
<LI><a href="link.html">Link
<LI><a href="link.html">Link
<LI><a href="link.html">Link
<LI><a href="link.html">Link
<LI><a href="link.html">Link
</UL>
</TD>
<TD>

------------------------

Finally, the end of the body ("bottom.inc.php"?) --


</TD>
</TR>
</TABLE>

------------------------


Now, you can set up your webpages as follows:

<HTML>
<HEAD>
<TITLE>Page Title Here</TITLE>
<?php require("head.inc.php"); ?>
</HEAD>
<BODY>
<?php require("top.inc.php"); ?>
Content goes here!
Content goes here!
Content goes here!
Content goes here!
Content goes here!
<?php require("bottom.inc.php"); ?>
</BODY>
</HTML>


Now each of your pages will automatically update whenever you change the links on your sidebar, which will be saved as a seperate file that only requires one update.
__________________
DevelopedWeb.com -
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
- a brand new online discussion area.
DevelopedWeb is offline
Reply With Quote
View Public Profile Visit DevelopedWeb's homepage!
 
Old 08-25-2004, 04:43 PM
webwoRRks's Avatar
Ultra Talker

Posts: 426
Location: I hope so
Trades: 0
if you only want the links though, bung them in a php file like this;

PHP Code:
<?php
$links 
= array();
$links["Google"] = "http://www.google.com";
$links["Sky news"] = "http://www.sky.com/news";

foreach(
$links as $key=>$value) {
   echo 
"<a href=\"$value\">$key</a><br />\n";
}
?>
then just require() that wherever you want the links shown.
__________________
Theres 10 types of people; those who understand binary, and those who don't.
webmaster and webdeveloper resources,
Please login or register to view this content. Registration is FREE
webwoRRks is offline
Reply With Quote
View Public Profile Visit webwoRRks's homepage!
 
Old 08-26-2004, 09:07 AM
Skilled Talker

Posts: 79
Trades: 0
You could make a seperate links page, eg links.php, and then include that in your pages (this is that I do).

So, you haev your links.php file and in it you type:
<a href="index.php">Home</a>
<a href="design.php">Design</a>
<a href="contact.php">Contact Us</a>
<a href="about.php">About Us</a>

Then, you have you individual page, which are just regular php/html pages. In the place where you want the link to be, you use the "include" command of php:

<p>this is my page....blah blha...</p>

<p>click the links below to tour the site:</p>

<!-- include links.php file here -->

<?php include("links.php"); ?>


Obviously, you will want to make it look pretty etc

This works well for me, and is very simple. This way, when you add a new link, just add it to the links.php file. It will change on every page.

Hope this helps.

Hamish
__________________

Please login or register to view this content. Registration is FREE
secure and fully automated computer data backup for small and medium sized companies.


Please login or register to view this content. Registration is FREE
hamish is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to add same text link on all of my html pages
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.20129 seconds with 12 queries