Индекс на шаблона PDF Печат Е-мейл
Автор Administrator   
29 април 2006
  
Целият индекс на шаблона е PHP файл, но той е написан изцяло на HTML с добавянето на няколко PHP функции. Трябва да научите единствено HTML и да поставите нужните редове за да си направите шаблон за Joomla.

Within the HTML framework you place "windows" that look into the Database behind your web Site. There are typically several small windows called Modules and usually one larger opening (like a frontdoor) for a Component.

You are encouraged to write Templates in XHTML. While there is debate over whether XHTML *is* the way of the future, it is a well formed XML standard, whereas HTML is a loose standard.  Future versions of Joomla will rely more and more on XML so it is wise to adopt this model now.

The index.php file for a typical 3-column layout would look like the following in a skeletal form:
 1: <?php
 2: $iso = explode( '=', _ISO );
 3: echo '<?xml version="1.0" encoding="' . $iso[1] . "\"?>\n";
 4: /** ensure this file is being included by a parent file */
 5: defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
 6: ?>
 7: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 8: <html xmlns="http://www.w3.org/1999/xhtml" lang="<?php echo _LANGUAGE; ?>">
 9: <head>
10:   <Title><?php echo $mosConfig_sitename; ?></title>
11:   <meta http-equiv="Content-Type" content="text/html; <?php echo _ISO; ?>" />
12: <?php
13: if ($my->id) {
14:   initEditor();
15: }
16: ?>
17: <?php mosShowHead(); ?>
18: <link href="<?php echo $mosConfig_live_site;?>/templates/basic_template/css/template_css.css"
          rel="stylesheet" type="text/css" />
19: </head>
20: <body>
21: <table cellspacing="0" cellpadding="5" border="0">
22:   <tr>
23:     <td colspan="3">
24:       <?php echo $mosConfig_sitename; ?>
25:     </td>
26:   </tr>
27:   <tr>
28:     <td colspan="3">
29:       <?php mosLoadModules ( 'top', 1 ); ?>
30:     </td>
31:   </tr>
32:   <tr>
33:     <td width="20%" valign="top">
34:       <?php mosLoadModules ( 'left' ); ?>
35:     </td>
36:     <td width="60%" valign="top">
37:        <?php mosMainBody(); ?>
38:     </td>
39:     <td width="20%" valign="top">
40:       <?php mosLoadModules ( 'right' ); ?>
41:     </td>
42:   </tr>
43:   <tr>
44:    <td colspan="3" valign="top">
45:      <?php mosLoadModules ( 'bottom' ); ?>
46:    </td>
47:  </tr>
48: </table>
49: </body>
50: </html>

Нека да разгледаме написаното до тук ред по ред.

Линия 1-3: Дефинира файла като валиден XML файл.  _ISO дефинира енкодинга, който ще се използва.  Той е дефиниран във вашият езиков файл.

Линия 5: Предотвратява директния достъп до този файл.

Линия 7-8: Задава XHTML стандарти за страницата.

Линия 10: Показва Името на сайта.

Линия 11: _ISO се използва отново за енкодинга на сайта.

Линия 12-16: $my->id is a script variable that is non-zero if a user is logged in to your site. If a user is logged in then the nominated WYSIWYG Editor is pre-loaded. You may, if you wish, always pre-load the Editor but generally an anonymous visitor will not have the need to add content. This saves a little script overhead for normal browsing of your site.

Line 17: Inserts several metadata blocks.

Lines 18: Loads the CSS stylesheet. $mosConfig_live_site is a configuration variable that holds the absolute URL of your site.

Line 24: This prints the Site Name in a table cell (spanning the three columns).

Line 29: This loads any modules that are Publish(ed) in the "top" position. The second argument, "1", indicates that the modules are to be aligned horizontally.

Line 34: This loads any modules that are published in the "left" position. These modules will be displayed in a single column.

Line 37: This loads the component into your template. The component is set by the URL, for example, index.php?option=com_content will display the Content Component in this area.

Line 40: This loads any modules that are published in the "right" position. These modules will be displayed in a single column.

Line 45: This loads any modules that are published in the "bottom" position.

Последна промяна ( 29 април 2006 )
 
< Предишна   Следваща >