An Introduction to Dreamweaver and PHP Part A

  • Slides: 56
Download presentation
An Introduction to Dreamweaver and PHP Part A: The Dreamweaver environment and some simple

An Introduction to Dreamweaver and PHP Part A: The Dreamweaver environment and some simple HTML and Style 1

Goals Our goals are • To become familiar with the Dreamweaver environment • To

Goals Our goals are • To become familiar with the Dreamweaver environment • To introduce some basic HTML • To introduce some simple PHP • To compare simple PHP (server-side) code with simple Java. Script (client-side) code We will do so by designing a page that looks like the following. 2

Open Dreamweaver (maybe in Adobe folder) 3

Open Dreamweaver (maybe in Adobe folder) 3

On the first use of Dreamweaver, it will ask what file types you chose

On the first use of Dreamweaver, it will ask what file types you chose to edit using Dreamweaver 4

Select the type of file – in our case PHP 5

Select the type of file – in our case PHP 5

PHP versus HTML: The php extension • PHP code is embedded within HTML code.

PHP versus HTML: The php extension • PHP code is embedded within HTML code. • However, a page with PHP code must have the php extension and not the htm or html extension. – Because the PHP is embedded within HTML, we will still often refer to the file as an HTML document. • Why the php extension? 6

Why the php extension? : A note about clients and servers • There are

Why the php extension? : A note about clients and servers • There are two main actors involved in viewing a webpage. 1. The viewer’s computer acts as a client. When surfing or navigating to a page, the client machine requests a page be sent. 2. With the webpage is associated a web server, which handles the request and delivers a response (the page) to the client. • The php extension informs the server that it must do more than just send the file. Moreover, there must be an associated PHP server to perform this extra work. 7

Note the views: Code, Design and Split. Design is currently selected. 8

Note the views: Code, Design and Split. Design is currently selected. 8

In Code View Although we are making a php file, thus far we have

In Code View Although we are making a php file, thus far we have a simple HTML file. 9

HTML • HTML stands for Hypertext Markup Language. – Hypertext refers to the presence

HTML • HTML stands for Hypertext Markup Language. – Hypertext refers to the presence of links in a page. The links allow a viewer to move directly to another document that may have a different location. – Markup Language refers to a coding system that indicates how a document is structured or how it should be rendered (using ordinary printable characters rather than special control characters). 10

HTML Tags • To distinguish between text and the marking up thereof, HTML uses

HTML Tags • To distinguish between text and the marking up thereof, HTML uses tags. • HTML tags are keywords placed within angle brackets <>. • Many HTML tags work in pairs. There is an opening tag and a closing tag which impose their effect on the hypertext enclosed between them. – The closing tag has the same keyword as the opening tag but the keyword is preceded by a slash. 11

 • The example above shows some HTML tag pairs. – The <html> and

• The example above shows some HTML tag pairs. – The <html> and </html> pair surround the HTML document. – The <head> and </head> pair enclose some explanatory information regarding the document. – The <title> and </title> pair contain the document’s title. – The <body> and </body> pair house the information that is to be rendered on the page. • Note the hierarchical structure of tag pairs within tag pairs (also called nesting). 12

Make sure Dreamweaver is generating reasonably modern code 13

Make sure Dreamweaver is generating reasonably modern code 13

Use File/Convert if you wish to change your “compliance” version 14

Use File/Convert if you wish to change your “compliance” version 14

To change the page’s title, edit either textbox on the document toolbar or the

To change the page’s title, edit either textbox on the document toolbar or the text between the <title> tags 15

To add a comment, place the cursor where you want the comment and go

To add a comment, place the cursor where you want the comment and go to Insert/Comment on the menubar. A traditional comment has no effect on either the structure or rendering of the document. It is seen only when the code is viewed and is used to describe the page or some feature thereof. 16

The comment is placed between the <!-- and the -->. 17

The comment is placed between the <!-- and the -->. 17

To change some of the page’s features such as the font or the background,

To change some of the page’s features such as the font or the background, go to Modify/Page Properties on the menubar. 18

The resulting dialog box allows one to set various properties. 19

The resulting dialog box allows one to set various properties. 19

E. g. use the dropdown list to make a choice of font family. 20

E. g. use the dropdown list to make a choice of font family. 20

Font family explanation 21

Font family explanation 21

Click on the palette button next to Text color to choose a font color.

Click on the palette button next to Text color to choose a font color. 22

Color Codes • One could also enter the color code for one’s choice in

Color Codes • One could also enter the color code for one’s choice in the corresponding textbox. • In HTML color codes use the RGB scheme in which one determines the amount of red, green and blue that will be combined to make the color by choosing three numbers each between 0 and 255. • The numbers are expressed as hexadecimal numbers (base 16) and concatenated (placed one after another) and preceded by a pound sign #. 23

RGB Code for Gray in Logo This screen capture shows using the eyedropper tool

RGB Code for Gray in Logo This screen capture shows using the eyedropper tool in Photoshop and the Color palette to determine the RGB values for the dark blue of the logo. 24

Logo dark blue color code calculation 2 To convert from decimal numbers to hexadecimal

Logo dark blue color code calculation 2 To convert from decimal numbers to hexadecimal numbers, you can use the calculation under Start/Programs/ Accessories/Calculator. Click on View/Scientific and enter the decimal number to be converted. And the click on the Hex radio button. The result should have two hexadecimal digits (0 -9 or A-F). If the result has only one digit, a “ 0” should be placed in front of it. Putting the Red, Green and Blue results together yields Logo gray: #003366 25

Primary La Salle Colors • Blue – 003366 • 6685 A 3 • BBC

Primary La Salle Colors • Blue – 003366 • 6685 A 3 • BBC 9 D 6 • E 8 EDF 1 (0, 51, 102) (102, 133, 163) (187, 201, 214) (232, 237, 241) • Yellow – FFCC 00 • FFEEA 8 • FFFFCC (255, 204, 0) (255, 238, 168) (255, 204)

Secondary La Salle Colors • • • CC 3333 CC 6633 669999 CCCCCC 33

Secondary La Salle Colors • • • CC 3333 CC 6633 669999 CCCCCC 33 CC→ 204; 60 → 96; DA → 218 336060 E 0 E 0 C 2 666666 ECECDA 99 → 153; E 0 → 224; 33 → 51; EC → 236

Use the Browse button and the resulting dialog box to locate an image file

Use the Browse button and the resulting dialog box to locate an image file to use as a background. 28

Path warning message 29

Path warning message 29

Embedded versus referred to • When one inserts an image in a Word document,

Embedded versus referred to • When one inserts an image in a Word document, the image is embedded into the Word document. As a result if you want someone to view the document, you only need to send one file – the Word document. • When one inserts an image in an HTML document, the image is referred to by the HTML document. As a result if you want someone to view the document, you must send two files – the HTML document and the image file. 30

Relative versus Absolute Path • When the HTML document refers to the image file,

Relative versus Absolute Path • When the HTML document refers to the image file, it provides a path so that the image file can be located. – A file’s path may be absolute (a complete (full) path or an explicit, full URL, e. g. http: //www. lasalle. edu/index. htm) or relative (a shorter path that starts with the same location as the file doing the referring). • Image files are generally referred to by a relative address. – The previous warning message occurred because we had not saved the HTML file. Since the HTML file had no location, a relative address could not be provided for the image file. 31

Note the address given refers to the computer’s C or D drive. This address

Note the address given refers to the computer’s C or D drive. This address will probably be useless when the file is moved to a web server where it can be viewed by clients. 32

Modify/Page Properties, select Links category 33

Modify/Page Properties, select Links category 33

Style tags • The new additions were placed in a style tag in the

Style tags • The new additions were placed in a style tag in the head portion of the document. • The actual style code was then placed inside a comment within the style tags. • This approach is used to deal with various versions of browsers. – If the browser understands the style tag, it knows to look in the comment for the style code. – If the browser does not understand the style tag, then it will ignore the style code since it is placed in a comment. 34

Cascading Style Sheet • If one is making a website consisting of many web

Cascading Style Sheet • If one is making a website consisting of many web pages that will have the same style, then a better approach is to place this style code in a separate file called a cascading style sheet (CSS) file and have all of the individual pages link to it. • This way we only have to change one file to update the style of all of the pages. 35

Next use the File/Save As option on the menubar and the resulting dialog box

Next use the File/Save As option on the menubar and the resulting dialog box to save the file. Recall it should have a php extension. (Do not have spaces in the file name. ) 36

In this case, Dreamweaver automatically updated the path to a relative path. 37

In this case, Dreamweaver automatically updated the path to a relative path. 37

One can see what the page will look like in Design view or see

One can see what the page will look like in Design view or see code and design simultaneously in Split view. There is a yellow stripe from the background image. That it is striped may not be noticeable in these screen captures. 38

Use Insert/Table on the menubar and the resulting dialog box to make a table

Use Insert/Table on the menubar and the resulting dialog box to make a table with 4 rows and 2 columns. 39

Use the Property inspector to alter the background color and alignment. Expand the Property

Use the Property inspector to alter the background color and alignment. Expand the Property inspector if needed 40

Click in the top cell and drag across to highlight both cells in the

Click in the top cell and drag across to highlight both cells in the top row, then go to Modify/Table/Merge Cells. 41

Table with merged cells in Design and in Code View (merging is achieved by

Table with merged cells in Design and in Code View (merging is achieved by colspan attribute in code) 42

Table Tags • The main tags involved in rendering a table are – The

Table Tags • The main tags involved in rendering a table are – The <table> </table> tags, which “delimit the table” – that is, indicate where the table code begins and ends. – The <tr> </tr> (table row) tags, which delimit a row within the table. – The <td> </td> (table data) tags, which delimit a cell within a row. 43

Webopedia delimiter definition 44

Webopedia delimiter definition 44

Tag Attributes • Note that the merged cells were achieved using the keyword colspan

Tag Attributes • Note that the merged cells were achieved using the keyword colspan as follows <td colspan="2">  </td> • The above code is an example of a tag with an attribute. • In the newer (more compliant) rules for HTML code attributes are set using a equal sign and the value in quotation marks. 45

Place the cursor in the top row, go to Insert/Image on the menubar, and

Place the cursor in the top row, go to Insert/Image on the menubar, and use the dialog box to locate the (fake) ACT logo image file Note that the image preview tells one the size of the image. 46

Add the alternate and long description attributes

Add the alternate and long description attributes

Accessibility Compliance

Accessibility Compliance

Logo added to first row 49

Logo added to first row 49

Style attribute of td element In code view, adding style=“ leads to a drop-down

Style attribute of td element In code view, adding style=“ leads to a drop-down list of possibilities for the style of the table data element.

The td attributes in code and design view

The td attributes in code and design view

Right click on the image, go to Make Link on the context sensitive menu,

Right click on the image, go to Make Link on the context sensitive menu, enter La Salle’s homepage in the URL textbox. Click OK. 52

Hyperlink code

Hyperlink code

Code for hyperlinked logo • The resulting code is <a href="http: //www. lasalle. edu/technology/in

Code for hyperlinked logo • The resulting code is <a href="http: //www. lasalle. edu/technology/in dex. php"> <img src="act_logo. gif" alt="ACT logo" width="450" height="150" /> </a> – Where <a> is the anchor tag and its href attribute is set to the destination URL. 54

Aspect Ratio • If one were to change the image size attributes, width and

Aspect Ratio • If one were to change the image size attributes, width and height, they should be changed proportionately to maintain the image’s aspect ratio. – Both numbers should be multiplied (or divided) by the same amount. – Alternatively, if one attribute is left unspecified, then the other will be set to maintain aspect ratio. 55

References • PHP for the World Wide Web, 2 nd edition, Larry Ullman, Peachpit

References • PHP for the World Wide Web, 2 nd edition, Larry Ullman, Peachpit Press, 2004. • http: //www. webopedia. com 56