Create a basic index.php file: Difference between revisions
From Joomla! Documentation
m fixed inline HTML Tag < |
Some markup changes. |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
The index.php file becomes the core of every page that Joomla! delivers. Essentially, you make a page (like any | The ''index.php'' file becomes the core of every page that Joomla! delivers. Essentially, you make a page (like any HTML page) but place PHP code where the content of your site should go. | ||
For many reasons ( | For many reasons (bandwidth, accessibility, and W3C standards compliance) you will want to make the ''index.php'' file as small as possible and use a separate CSS file for styling. This example shows how to create a simple layout using the ''<nowiki><div></nowiki>'' tag. | ||
Lets start at the top: | Lets start at the top: | ||
< | <syntaxhighlight lang="html4strict"> | ||
<?php defined( '_JEXEC' ) or die( 'Restricted access' );?> | <?php defined( '_JEXEC' ) or die( 'Restricted access' );?> | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml" | <html xmlns="http://www.w3.org/1999/xhtml" | ||
xml:lang="<?php echo $this->language; ?>" | xml:lang="<?php echo $this->language; ?>" | ||
lang="<?php echo $this->language; ?>" > | lang="<?php echo $this->language; ?>" > | ||
</ | </syntaxhighlight> | ||
The first line stops naughty people looking at your coding and getting up to bad things. The second tells the browser (and webbots) what sort of page it is. The third line says what language the site is in. | The first line stops naughty people looking at your coding and getting up to bad things. The second tells the browser (and webbots) what sort of page it is. The third line says what language the site is in. | ||
Now the header | Now the header: | ||
< | <syntaxhighlight lang="php"> | ||
<head> | <head> | ||
<jdoc:include type="head" /> | <jdoc:include type="head" /> | ||
<link rel="stylesheet" | <link rel="stylesheet" | ||
href="<?php echo $this->baseurl; ?>/templates/mynewtemplate/css/css.css" | href="<?php echo $this->baseurl; ?>/templates/mynewtemplate/css/css.css" | ||
type="text/css" /> | type="text/css" /> | ||
</head> | </head> | ||
</ | </syntaxhighlight> | ||
The first line gets Joomla to put the correct header information in. The second creates a link to your style sheet. You will need to change this to the directory name that you chose. | The first line gets Joomla to put the correct header information in. The second creates a link to your style sheet. You will need to change this to the directory name that you chose. | ||
Now for the main body: | Now for the main body: | ||
< | <syntaxhighlight lang="html4strict"> | ||
<body> | <body> | ||
</body> | </body> | ||
</ | </syntaxhighlight> | ||
Latest revision as of 16:11, 31 October 2022
The index.php file becomes the core of every page that Joomla! delivers. Essentially, you make a page (like any HTML page) but place PHP code where the content of your site should go.
For many reasons (bandwidth, accessibility, and W3C standards compliance) you will want to make the index.php file as small as possible and use a separate CSS file for styling. This example shows how to create a simple layout using the <div> tag.
Lets start at the top:
<?php defined( '_JEXEC' ) or die( 'Restricted access' );?>
<!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"
xml:lang="<?php echo $this->language; ?>"
lang="<?php echo $this->language; ?>" >
The first line stops naughty people looking at your coding and getting up to bad things. The second tells the browser (and webbots) what sort of page it is. The third line says what language the site is in.
Now the header:
<head>
<jdoc:include type="head" />
<link rel="stylesheet"
href="<?php echo $this->baseurl; ?>/templates/mynewtemplate/css/css.css"
type="text/css" />
</head>
The first line gets Joomla to put the correct header information in. The second creates a link to your style sheet. You will need to change this to the directory name that you chose.
Now for the main body:
<body>
</body>