Question 9.1: Unzip the archive
file tutorial-9.tar.gz
using Winzip or the tar command for the purposes of completing
this tutorial.
§ 9.1 Uploading your Website to Ripway
Question 9.2:
Use the program FTP (Note that F.T.P. stands for
File Transfer Protocol) to transfer all of the
files in the folder tutorial-9 to your Ripway account. To do
this you will need to follow the following steps:
Open an MS-DOS command prompt
Change directory to the tutorial-8 folder using the cd command.
Start FTP by entering the command ftp ftphost.ripway.com.
Enter your Ripway user name and password that you created in the last tutorial.
Enable "Binary Transfer Mode" using the command binary (or bin for short).
Binary transfer mode is essential for images to be transmitted successfully.
Turn "Interactive Mode" to off using the command prompt (or pro for short).
Transfer all files using the command mput *
Wait for the files to be transmitted.
Leave the FTP program running so you can upload files at a later time.
Load your Website into a Web browser to make sure your Website has been transfered successfully.
When you have finished doing this, you should browse your Ripway
Website to verify that all files (P.H.P. and image) have been uploaded
successfully.
Question 9.3: Then check that the sub-menus of the page inner
work propertly.
Question 9.4: Change the variable $logo in the file
tutorial-9/index.inc to something more appropriate to your
Website. Also change the file tutorial-9/index.php so that it
says: Welcome to Your Name's Website! and displays an image that
is more appropriate to your Website.
§ 9.2 Sub-menus and sub-sub-menus
§ 9.2.1 How to create sub-menus of a given page
Let the file of the page that you want to create sub-menus of be
denoted by X.php.
Let the title of the page that you want to create sub-menus of be
denoted by TITLEX.
Let M.inc denote the menu page of X.php.
Let COLOR denote the colour of the sub menus inside the page
X.php in the form #RRGGBB, for example #ff8844. It is
cosmetically important that the colours of your sub-menus differ from
the colours of all other menus in your Website.
Suppose you want to create N sub-menus in the page X.php.
Suppose the sub-menu files are
FILE1,FILE2,FILE3, . . . ,FILEN. Note
that the files will be prefixed with X- so that you know that
they are sub-pages of X.php.
Suppose the sub-menu titles are
TITLE1,TITLE2,TITLE3, . . . ,TITLEN.
Create a file X.inc containing the following:
<?php
include "M.inc";
$button_col_bglo = "COLOR";
for each sub-menu I in the set 1,2,3,...,N add a line that says: button("X-FILEI.php","TITLEI");
$back_to = "<a href=X.php>Back to TITLEX Page</a>";
?>
For each I in the set 1,2,3,...,N Create a page
X-FILEI.php containing the following:
<?php
$file = "X-FILEI.php";
$title = "TITLEI";
include "X.inc";
include "root-second.inc";
?>
Your text for each page goes here
<?php
include "root-last.inc";
?>
Change the first include in X.php to: include "X.inc";
Let the parent title of the page that you want to create
sub-menus of be denoted by TITLEP.
Change the $backto setting near the bottom of X.php to:
$backto = "<a href=M.php>Back to TITLEP</a>";
Question 9.5: Add sub-menus apple-1.php, apple-2.php and
apple-3.php to the page apple.php. Upload your changes
using the command mput *.php *.inc and use a Web browser to
check that the sub-menus have been added successfully.
Question 9.6: Add sub-menus apple-1-1.php, apple-1-2.php and
apple-1-3.php to the page apple-1.php. Upload your changes using
the FTP command mput *.php *.inc and use a Web browser to check
that the sub-menus have been added successfully.
§ 9.2.2 How to delete sub-menus of a given page
Let the file of the page that you want to delete sub-menus from
be denoted by X.php.
Suppose there are N sub-menus of the page X.php.
Suppose the sub-menu files are
FILE1,FILE2,FILE3, . . . ,FILEN.
Delete the file X.inc. This will delete the menu
buttons for the sub-pages that you want to delete.
Delete the files X-FILEI.php for each I in the
set 1,2,3,...,N. This will delete the sub-pages from your
Website.
Delete the $backto= command in X.php.
Change the first include in X.php from X.inc to the
value at the top of X.inc.
Question 9.7: Delete sub-menus inner-1.php, inner-2.php and
inner-3.php from the page inner.php. Upload your changes
using the FTP commands mdelete *.php *.inc and mput *.php
*.inc and use a Web browser to check that the sub-menus has been
deleted successfully.
Question 9.8: After you have answered the previous question and
verified that it did delete the sub-menus, delete the page
inner.php. Go back to Section § 8.5.4 if you cannot remember
how to do this. Upload your changes using the FTP commands
mdelete inner.php and mput inner.* and use a Web browser
to check that the page has been deleted successfully.
Question 9.9: Swap the following variables at the top of the files
*.inc:
Replace $button_col_fglo with $button_col_bglo
Replace $button_col_fghi with $button_col_bghi
Replace $button_col_bglo with $button_col_fglo
Replace $button_col_bghi with $button_col_fglo
Save the files that you have edited and upload your changes to
Ripway using the FTP command mput *.inc. View your Website in
a Web browser and verify that the background and foreground colours
of all of the menu buttons have been reversed.
§ 9.3 How to answer the following questions
Every file that you edit will need to be transmitted using the program
FTP before you can load your Website into a Web browser. For
example, if you edit stylesheet.css and index.php, then
you will need to issue the command: mput stylesheet.css
index.php.
§ 9.4 Introduction to Cascading Style Sheets
Recall from Section § 1.4 that you cannot specify the background
colour of text using <font> tags. To do this you will need to
use Cascading Style Sheets (or C.S.S. for short). Cascading Style
Sheets are also useful because it allows you to separate the logic
of your H.T.M.L. code from the layout (which is purely cosmetic).
.
Although C.S.S. code can legally be put in every P.H.P. file, it is
better to factor it out of the P.H.P. file and have one C.S.S. file
that applies to all P.H.P. files. This is the approach that is
taken in the Website associated with this tutorial. Therefore when
you want to change the C.S.S. file, you only need to do it in one
place: tutorial-9/stylesheet.css and the changes will be
reflected in every Web page of the Website.
To access the file stylesheet.css in every Web page of your
Website each H.T.M.L. Web page will need to look like this:
For the purposes of this tutorial, you don't need to add this code
to every page of your Website because it is automatically included.
See the file index.inc for one of the echo commands.
The information in this section is given in case you are using plain
H.T.M.L. documents, in which case you will have to manually add this
code to the top of every page in your Website..
Span tags provide a way for you to specify the background colours of
text. Here is an example of the definition of a span tag in the
file stylesheet.css:
With this code in place you can create text which is in the courier
font, with bold and italics turned on, has a black background and a
red foreground. You cannot do this with the <font> tag. Here
is how to use this font in an H.T.M.L. document:
<span class="rb">I have a red foreground and a black background.</span>
Note that all of the entries in the definition of the span tag are
optional. When specifying colours such as the color: or
background: attributes, you can use hexadecimal RGB colour
triplets (as is done above), or you can name colours explicitly
using a colour
name such as red. The third way to do this is by using a
RGB decimal triplet such as rgb(255,0,0);. Legal values for the
font-family: attribute include: Times, Courier,
San-Serif (also known as Helvetica) and Comic Sans MS.
Question 9.10: Add code to stylesheet.css to create a span tag
with class name myspan with no bold, no italics, Helvetica font,
green background and yellow foreground. Add some H.T.M.L. code to
tutorial-9/index.php so that some text is shown with the span
class myspan and finally open index.php in a Web
browser to verify that <span> tags are correctly rendered.
§ 9.4.1.1 Multiple values for the font-family: attribute
When specifying a font like Comic Sans MS which may not exist in
non-Windows computers, it is wise to give one or more alternative
fonts in case the first one doesn't exist. Consider the following
C.S.S. code.
span.comic
{
font-family: 'Comic Sans MS', Helvetica;
}
In the above, note that Comic Sans MS needs to be quoted as it has
spaces in it. Then consider the following H.T.M.L. code:
<span class="comic">I might be in the Comic Sans MS font.</span>
The above sentence will appear in the Comic Sans MS font, and if
that font doesn't exist, it will appear in the Helvetica font.
§ 9.4.2 <h1> - <h6> tags
Here is a definition of the <h1> tag to go in stylesheet.css:
With the above definition in place, whenever you write a pair of
tags <h1> . . . </h1> it will show up in courier face, bold,
italic, red foreground, black background, right text alignment and
font size 40pt.
Question 9.11: Using similar code to the above, write a C.S.S. definition
so that <h2> tags show up with center alignment and green
foreground and no other styles. Change index.php so
that it contains an <h2> tag and finally open index.php in a Web
browser to verify that <h2> tags are correctly rendered.
Question 9.12: Write a C.S.S. definition so that <h3> tags show up
with left alignment, green foreground and a yellow background and no
other styles. Change index.php so that it contains
an <h3> tag and finally open index.php in a Web
browser to verify that <h3> tags are correctly rendered.
Question 9.13: Write a C.S.S. definition so that <h4> tags show up
with left alignment, green foreground, yellow background, orange
left borders, orange bottom borders and no other styles. The
following code will help you to achieve this:
border-bottom: medium solid rgb(255, 128, 0);
border-left: medium solid rgb(255, 128, 0);
and finally open index.php in a Web
browser to verify that <h4> tags are correctly rendered..
§ 9.4.3 <p> tags
Here are some attributes that you can apply to default text:
Question 9.18: Write some C.S.S. code so that the background image in
your Website is different to the one above, and does repeat, but is
not fixed, so that it scrolls whenever you scroll the screen. See
the following Website:
www.w3schools.com/css/css_background.asp for more
information.