 |
|
 |
|
Next: Affordablehost down again - sharp decrease in rel..
|
| Author |
Message |
External

Since: Sep 24, 2003 Posts: 3
|
(Msg. 1) Posted: Thu Sep 25, 2003 2:07 am
Post subject: Replacing Javascript with PHP to write HTML Archived from groups: alt>www>webmaster (more info?)
|
|
|
I've got a situation that I need to fix, but I don't know how and I don't
know what I'm looking for is called. I was hoping someone here can help.
Currently, I have a site that is basically set up like this:
HEADER
MENU MAIN CONTENT
FOOTER
The header, menu, and footer are the same on all pages, and the "main
content" is different for each page. Currently I do not use style sheets,
and all of the HTML for all elements of each page is on the pages - except
for the menu. When I set up the pages years ago, I anticipated the menu
changing periodically, so instead of having the menu hard-coded into each
page, I used Javascript to write the menu in, like this:
<p><SCRIPT LANGUAGE="JavaScript" SRC="menu.js"></SCRIPT>
The script uses "document.writeln" to just write the HTML of the menu (text
& links). Needless to say, this is a bad idea. So I was wondering if there
was a way to use PHP to write the menu into each page instead of using
Javascript? And if I'm "linking" to code for the menu, I thought I might as
well do the same for the header and footer, so that if any of those elements
change I can just change the files containing the code for the header and
footer so I don't have to update each page when there is a change.
Furthermore, it seems to me that using style sheets to accomplish this would
be a much better idea, but from the examples I've seen style sheets don't
cover quite what I'm looking to do. Of course, I could be wrong.
How can I use PHP to write content into a file similar to "document.writeln"
for Javascript?
Many thanks to anyone who can assist! >> Stay informed about: Replacing Javascript with PHP to write HTML |
|
| Back to top |
|
 |  |
External

Since: Jul 03, 2003 Posts: 98
|
(Msg. 2) Posted: Thu Sep 25, 2003 7:02 am
Post subject: Re: Replacing Javascript with PHP to write HTML [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article <vn4n08h742o5cb.DeleteThis@corp.supernews.com>, JJ wrote:
>
> How can I use PHP to write content into a file similar to "document.writeln"
> for Javascript?
>
> Many thanks to anyone who can assist!
>
>
something like:
good idea to keep the various include files outside the web tree and each
include file can have html code of its own and other include file if necessary
/// code for index.php
<?php
include ("metainfo.php");
include ("headerinfo.php");
?>
some html code
<?php
include ("menuarray.php");
// a section to draw content from a databse or other text file
?>
some more html code
<?php
include ("footer.php");
?>
kb<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: Replacing Javascript with PHP to write HTML |
|
| Back to top |
|
 |  |
External

Since: Sep 24, 2003 Posts: 3
|
(Msg. 3) Posted: Thu Sep 25, 2003 7:02 am
Post subject: Re: Replacing Javascript with PHP to write HTML [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
> include ("footer.php");
What would the structure of footer.php be in this example? I'm just starting
to get into PHP, & I don't know how to make it write straight HTML. Does teh
PHP file have to have special instructions in it, or would it just be the
regular HTML code but instead of an HTML extension it is PHP?
Thanks for your help!<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: Replacing Javascript with PHP to write HTML |
|
| Back to top |
|
 |  |
External

Since: Jul 03, 2003 Posts: 98
|
(Msg. 4) Posted: Thu Sep 25, 2003 7:55 am
Post subject: Re: Replacing Javascript with PHP to write HTML [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article <vn4qg8sbfbul68.DeleteThis@corp.supernews.com>, JJ wrote:
>> include ("footer.php");
>
> What would the structure of footer.php be in this example? I'm just starting
> to get into PHP, & I don't know how to make it write straight HTML. Does teh
> PHP file have to have special instructions in it, or would it just be the
> regular HTML code but instead of an HTML extension it is PHP?
>
> Thanks for your help!
There are number of ways you can handle something like a footer file, or
header file or content file.
You can make, for example, the footer file all php code or a mix of php code
and html code.
All php code for footer.php
<?php
echo "<table><tr><td>some text here</td></tr></tab>";
?>
or
<!--this is your regular html code -->
<table><tr>
<?php
//$variable_text would equal some query to a database for example
//or a variable from an included configuration file, maybe the variable might
//equal a copyright date from you main config file.
echo "<td>$variable_text</td>"
?>
<!--this is your regular html code -->
</td></tr></tab>
If you're trying to learn by uploading files etc to your hosting account and
running scripts, it will be a difficult process. If you're running window
you can set up php on any windows machine with or without apache and mysql,
if you're running linux you can download the rpms or download the source and
compile the programs yourself. You should have php installed on your
computer, it will flatten out the learning curve...in the end it makes the
development process smoother.
Also check out <a style='text-decoration: underline;' href="http://onlamp.com/php" target="_blank">http://onlamp.com/php</a> for additional info.
kb<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: Replacing Javascript with PHP to write HTML |
|
| Back to top |
|
 |  |
External

Since: Sep 16, 2003 Posts: 19
|
(Msg. 5) Posted: Thu Sep 25, 2003 5:43 pm
Post subject: Re: Replacing Javascript with PHP to write HTML [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
It sounds like you minimally need SSI (HTML Server Side Includes) and could
easily use PHP includes for your standard sections (Header, Footer ...).
There are lots of good PHP getting started tutorials online. I suggest you
start with a Google search for these.
You are also talking about using CSS for positioning your sections. I am
moving to this method as well (I think it is going to be much better than
tables). Once again, find the tutorials for this online. Here is a good
place to start: <a style='text-decoration: underline;' href="http://www.sitepoint.com/article/1172." target="_blank">http://www.sitepoint.com/article/1172.</a>
Regards,
Bryan
"JJ" <fakeaddie.TakeThisOut@preventspam.edu> wrote in message
news:vn4n08h742o5cb@corp.supernews.com...
> I've got a situation that I need to fix, but I don't know how and I don't
> know what I'm looking for is called. I was hoping someone here can help.
>
> Currently, I have a site that is basically set up like this:
>
> HEADER
> MENU MAIN CONTENT
> FOOTER
>
> The header, menu, and footer are the same on all pages, and the "main
> content" is different for each page. Currently I do not use style sheets,
> and all of the HTML for all elements of each page is on the pages - except
> for the menu. When I set up the pages years ago, I anticipated the menu
> changing periodically, so instead of having the menu hard-coded into each
> page, I used Javascript to write the menu in, like this:
>
> <p><SCRIPT LANGUAGE="JavaScript" SRC="menu.js"></SCRIPT>
>
> The script uses "document.writeln" to just write the HTML of the menu
(text
> & links). Needless to say, this is a bad idea. So I was wondering if there
> was a way to use PHP to write the menu into each page instead of using
> Javascript? And if I'm "linking" to code for the menu, I thought I might
as
> well do the same for the header and footer, so that if any of those
elements
> change I can just change the files containing the code for the header and
> footer so I don't have to update each page when there is a change.
>
> Furthermore, it seems to me that using style sheets to accomplish this
would
> be a much better idea, but from the examples I've seen style sheets don't
> cover quite what I'm looking to do. Of course, I could be wrong.
>
> How can I use PHP to write content into a file similar to
"document.writeln"
> for Javascript?
>
> Many thanks to anyone who can assist!
>
><!-- ~MESSAGE_AFTER~ --> >> Stay informed about: Replacing Javascript with PHP to write HTML |
|
| Back to top |
|
 |  |
External

Since: Sep 25, 2003 Posts: 106
|
(Msg. 6) Posted: Thu Sep 25, 2003 7:27 pm
Post subject: Re: Replacing Javascript with PHP to write HTML [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
JJ wrote:
> I've got a situation that I need to fix, but I don't know how and I don't
> know what I'm looking for is called. I was hoping someone here can help.
>
> Currently, I have a site that is basically set up like this:
>
> HEADER
> MENU MAIN CONTENT
> FOOTER
>
> The header, menu, and footer are the same on all pages, and the "main
> content" is different for each page. Currently I do not use style sheets,
> and all of the HTML for all elements of each page is on the pages - except
> for the menu. When I set up the pages years ago, I anticipated the menu
> changing periodically, so instead of having the menu hard-coded into each
> page, I used Javascript to write the menu in, like this:
>
> <p><SCRIPT LANGUAGE="JavaScript" SRC="menu.js"></SCRIPT>
>
> The script uses "document.writeln" to just write the HTML of the menu (text
> & links). Needless to say, this is a bad idea. So I was wondering if there
> was a way to use PHP to write the menu into each page instead of using
> Javascript? And if I'm "linking" to code for the menu, I thought I might as
> well do the same for the header and footer, so that if any of those elements
> change I can just change the files containing the code for the header and
> footer so I don't have to update each page when there is a change.
>
> Furthermore, it seems to me that using style sheets to accomplish this would
> be a much better idea, but from the examples I've seen style sheets don't
> cover quite what I'm looking to do. Of course, I could be wrong.
>
> How can I use PHP to write content into a file similar to "document.writeln"
> for Javascript?
>
> Many thanks to anyone who can assist!
You have a few options other than PHP (PHP is a good option because it
is easy to do more difficult processing if you need it, and it is
supported by most hosts). SSI does all that you need to do and most
hosts support it, and it is tags like HTML which makes it a little less
daunting:
<a style='text-decoration: underline;' href="http://www.bignosebird.com/ssi.shtml" target="_blank">http://www.bignosebird.com/ssi.shtml</a>
Something like ASP is also an option but seems a little like overkill.
As far as PHP goes - put the segments of html common to all pages into
their own text files, eg header_info.txt, nav_info.txt and
footer_info.txt. You don't need any other tags, symbols or anything,
just the code that you want repeated. The file should look exactly the
same as if you were to use SSI as above (which is why I suggest this way
- it is compatible).
Then, when you want to include one of the files, put in this:
<?php
print(include("header_info.txt"));
?>
Obviously changing the file name to suit.
HTH<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: Replacing Javascript with PHP to write HTML |
|
| Back to top |
|
 |  |
External

Since: Sep 24, 2003 Posts: 3
|
(Msg. 7) Posted: Fri Sep 26, 2003 2:40 am
Post subject: Re: Replacing Javascript with PHP to write HTML [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
> If you're trying to learn by uploading files etc to your hosting account
and
> running scripts, it will be a difficult process. If you're running window
> you can set up php on any windows machine with or without apache and
mysql,
> if you're running linux you can download the rpms or download the source
and
> compile the programs yourself. You should have php installed on your
> computer, it will flatten out the learning curve...in the end it makes the
> development process smoother.
>
> Also check out <a style='text-decoration: underline;' href="http://onlamp.com/php" target="_blank">http://onlamp.com/php</a> for additional info.
Wow - thanks so much for the assistance!<!-- ~MESSAGE_AFTER~ --> >> Stay informed about: Replacing Javascript with PHP to write HTML |
|
| Back to top |
|
 |  |
External

Since: Sep 25, 2003 Posts: 106
|
(Msg. 8) Posted: Fri Sep 26, 2003 4:31 pm
Post subject: Re: Replacing Javascript with PHP to write HTML [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Bryan Carnathan wrote:
> It sounds like you minimally need SSI (HTML Server Side Includes) and could
> easily use PHP includes for your standard sections (Header, Footer ...).
> There are lots of good PHP getting started tutorials online. I suggest you
> start with a Google search for these.
>
> You are also talking about using CSS for positioning your sections. I am
> moving to this method as well (I think it is going to be much better than
> tables). Once again, find the tutorials for this online. Here is a good
<font color=purple> > place to start: <a style='text-decoration: underline;' href="http://www.sitepoint.com/article/1172.</font" target="_blank">http://www.sitepoint.com/article/1172.</font</a>>
Also:
<a style='text-decoration: underline;' href="http://glish.com/css" target="_blank">http://glish.com/css</a><!-- ~MESSAGE_AFTER~ --> >> Stay informed about: Replacing Javascript with PHP to write HTML |
|
| Back to top |
|
 |  |
| Related Topics: | Javascript help! - I've got the following script. <script language="javascript"> function pop_window(url) { var popit = window.open(url,'console','menubar,toolbar,location,directories,status,scrol lbars,resizable,width=584,height=636'); } I call it t...
New .com Domain - do internic write to you - Hi, I am wondering if someone would be able to help me here. I bought a .co.uk domain name back in March of this year and recently received a form (Registration Reply Form - Confirmation of Registration) to fill in from NominetUK send to me at my home..
Need a javascript snippet, please - Hi all; I'm hoping this is really simple, but I haven't been able to find the exact solution via Google: I have a site that displays a ton o' recipes and the client wants a printer-friendly version of the recipes that don't use any graphics and a ..
Javascript Question - You know how some links have javascript embedded in them? Like <a href="javascript:history.go(-1)"></a>... Would this still work if javascript is disabled? -- Sharif Tanvir Karim http://www.onlyonxbox.net
Help! Netscape Trouble with Javascript - Hi, I hope this problem I ran into has an easy fix. I created a menu bar for my page using Sothink DHTML Menu 4.1 which created javascript file. I also add a small slide show on the page using javascript and the javascript is embedded in this page's... |
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
 |
|
|