⬆️ ⬇️

Creating a Jooml template by standards - part 1 (continued)

This is a continuation of the article. Start here .





index.php


What is actually the index.php file? This is a combination of (X) HTML and PHP, which defines everything needed to display page elements.



First, look at the element that is essential for creating valid templates - the DOCTYPE at the top of the index.php file. This code snippet appears at the top of all web pages. On the pages of our template, we see the following:

')

 <? php // no direct access 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">




The first line in PHP is simply to make sure that the file is not accessed directly, for security reasons.



A web page's doctype is one of the fundamental parameters on the basis of which the browser decides how to display this page, in particular, how the browser interprets CSS. For a better understanding, here is a good quote from alistapart.com:



[Information on the W3C website about DOCTYPE] is compiled by geeks for geeks. And when I say “geeks,” I don’t mean ordinary Web professionals like you or me. I mean those geeks who make us look like Grandma on the day when She First Received an E-mail.



In any case, you can use different doctype. Essentially, the DOCTYPE tells the browser how to interpret the page. From the very beginning, when the Web appeared, different browsers had different levels of CSS support. For example, Internet Explorer will not understand the min-width command used to set the minimum page width. In order to duplicate the effect, you have to use the “hacks” in CSS.



Some say that processing XHTML as text / html should be considered “harmful”. If you truly understand this statement, then you are far beyond this guide. You can read more on this topic at hixie.ch/advocacy/xhtml . “Strict” means that HTML (or XHTML) must be interpreted exactly according to standards. And “Transitional” in DOCTYPE means that certain deviations from standards are allowed on the page.



To complicate the picture, we add that there is also the so-called “quirks” mode (special tweaks). If the DOCTYPE is entered incorrectly, with an incorrect date, or not specified at all, the browser switches to quirks mode. In fact, this is an attempt to provide backward compatibility, for example, Internet Explorer 6 would interpret the page as IE4 would have done.



Unfortunately, people sometimes accidentally switch to quirks mode. This usually happens for two reasons:

Source: https://habr.com/ru/post/41215/



All Articles