Bean HTML Modules PHP Name. Creating your own style for modules
We superficially touched the themes of content output methods in the Template body. Let us now look in detail what it is and with what it is eaten. So, the ads of the method jDOC is present in each joomla template and displayed into the body of the template (I mean the site page) of this or that information. In general, the ad method is as follows.
This line displays information on the site from components, such as Articles from COM_CONTENT. The type of output elements is specified in the attribute.
1. Type - Types of output elements.
- component. - As wrote above, displays the main content of the page. Can be called only once in the template.
- head. - declared just once after the operating tag . Serves to output styles, scripts,
and the current page metadata. - message- Displays system messages. Announced once in the body of the document (Body).
- installation. - nothing displays and represents "instructions" for installation.
- module -displays a single module on the page. The number of ads is not limited.
- modules. - Unlike the previous type, it allows you to output in its position not a single number of modules.
For the first four specified types, just specify them on the page. In the case of the type of module, the task is slightly complicated. In order to display the module on the page we need to first create for it modular position from unique identifier (Module's position name). This is done using the Name attribute \u003d "position name" and the mandatory addition of a string:
2. Style - Description of output style (MOD Chrome).
From the specified style depends appearance and the structure of the module shell. Looks like
:
- xHTML - Displays a module in a block with Function Modchrome_XHTML heading ($ Module, & $ Params, & $ ATTRIBS)
{
If (! Empty ($ Module-\u003e Content)):?\u003e
showtitle! \u003d 0):?\u003e
title; ?\u003e
content; ?\u003e
} - table -displays a module in the layout of the tabular structure
FUNCTION MODCHROME_TABLE ($ Module, & $ Params, & $ ATTRIBS)
{ ?>
showtitle! \u003d 0):?\u003e
title; ?\u003e
content; ?\u003e
} - horz -displays the contents of the module in the table cell, horizontally function modchrome_horz ($ Module, & $ Params, & $ ATTRIBS)
{ ?>
} - rounded. - Displays a module in several nested blocks for complex style design in the form of graphic boundaries (eg rounded angles) FUNCTION MODCHROME_ROUNED ($ Module, & $ Params, & $ ATTRIBS)
{ ?>
showtitle! \u003d 0):?\u003e
title; ?\u003e
content; ?\u003e
} - outline - adds to block module preset styles CSS FUNCTION Modchrome_outline ($ Module, & $ Params, & $ ATTRIBS)
{
Static $ CSS \u003d False;
If (! $ CSS)
{
$ CSS \u003d True;
jimport ("joomla.environment.browser");
$ doc \u003d jfactory :: getdocument ();
$ browser \u003d jbrowser :: getInstance ();
$ doc-\u003e addstyledeclaration (". mod-preview-info (Padding: 2px 4px 2px 4px; Border: 1px Solid Black; Position: absolute; background-color: White; color: red;)");
$ DOC-\u003e AddStyleDeclaration (". Mod-Preview-Wrapper (Background-Color: #ee; Border: 1px Dotted Black; Color: # 700;)");
if ($ browser-\u003e getBrowser () \u003d\u003d "MSIE")
{
If ($ Browser-\u003e GetMajor ()<= 7) {
$ DOC-\u003e AddStyleDeclaration (". mod-preview-info (Filter: Alpha (opacity \u003d 80);)");
$ DOC-\u003e AddStyledeclaration (". Mod-Preview-Wrapper (Filter: Alpha (opacity \u003d 50);)");
}
ELSE (
$ DOC-\u003e AddStyledeclaration (". mod-preview-info (-ms-filter: alpha (opacity \u003d 80);)");
$ Doc-\u003e AddStyleDeclaration (". mod-preview-wrapper (-ms-filter: alpha (opacity \u003d 50);)");
}
}
ELSE.
{
$ doc-\u003e addstyledeclaration (". mod-preview-info (OPACITY: 0.8;)");
$ DOC-\u003e AddStyledeclaration (". Mod-Preview-Wrapper (OPACITY: 0.5;)");
}
}
?>
position. "[". $ Module-\u003e Style. "]"; ?\u003e
content; ?\u003e
} - none - Similarly, not specified in general STYLE. Displays a module without registration and header Function Modchrome_None ($ Module, & $ Params, & $ ATTRIBS)
{
Echo $ Module-\u003e Content;
}
All preset styles are located in the TEMPLATES / SYSTEM / HTML / MODULES.php file. But we are not limited to the use of only the options provided, but may well create their own.
3. Creating a custom Mode Chrome.
So, the default types of modules representations do not satisfy current requirements. You need to add your own design style. As an example, choose a fairly repeated situation. On the task you need instead
Place the title of the module in tag which is semantically neutral. It is also necessary to place the content of the module in a separate . To create your own style output style, we use standard tools. In most templates, the Joomla has a folder HTML / (templates / template name / html /), is used for the so-called template. That is, if you copy the module template to this folder, then instead of the template from the Modules / My_Module / TMPL / DEFAULT directory, the file from templates / template name / html / my_modules / default will be displayed. Similarly, components are defined. Convenient and practical. In the HTML / folder of your template, create a Modules.php file. If there is no such folder in the template, then create it. In the file write fUNCTION MODCHROME_MODBOX ($ Module, & $ Params, & $ ATTRIBS) // Call a function
{
if (! Empty ($ module-\u003e content)): / * Check the presence in the search for the included module * /?\u003e
showtitle! \u003d 0): / * Check whether the module header is enabled * /?\u003e
title; / * Display the title * /?\u003e
content; / * Display the contents of the module * /?\u003e
}
?\u003e Ready. Now you only need to specify it as an output style. We assign a module to our position and see the result.
EM element is an excerpt of text with an emphasized accent. You can use it to draw the reader's attention to the meaning of the proposal or paragraph. I will tell you that it means, after which the EM element is described.
Table 8-6: Em element
Figure 8-3: Using EM element
In this example, I put the focus on I (I) at the beginning of the sentence. If you think about EM element, then when you pronounce a sentence, we consider the question that this offer is a response to the question. For example, imagine that I asked: "Who loves apples and oranges?" Your answer will be: "I love apples and oranges." (When you pronounce it out loud and put the focus on me, you give to understand that you are a person who loves these fruits).
But if I asked: "Do you like apples and what else?" You could answer: "I love apples and oranges (Oranges)." In this case, the emphasis will be made on the last word, emphasizing that oranges are another fruit you like. This option in HTML would look like this:
I Like Apples and
oranges.
.
Determination of foreign words and technical terms
The element I denotes a part of the text that has a different nature than the surrounding content. This is a rather vague definition, but general examples include words from other languages, technical or scientific terms and even human thoughts (in contrast to speech). The element I described.
Table 8-7: Element I.
Figure 8-5: Using the element S.
![](https://i2.wp.com/storage.smarly.net/html5/8.5.png)
Defining an important text
The Strong element denotes the text excerpt that is important. The in describes this item.
Table 8-9: Element strong
Figure 8-7: Using the Element U.
![](https://i2.wp.com/storage.smarly.net/html5/8.7.png)
Adding a small font
The small element indicates a small font and is often used for reservations and clarifications. The Small element is presented.
Table 8-11: Small element
Figure 8-8: Using the small element
![](https://i2.wp.com/storage.smarly.net/html5/8.8.png)
Adding upper and lower index
You can use the elements of SUB and SUP to indicate the upper and lower index, respectively. Upper indexes are used to write words in some languages, and both, upper and lower indices are used in simple mathematical expressions. These elements are presented.
Table 8-12: Elements sub and sup
Figure 8-9: Use sub and sup elements
Chrome is the final processing of the HTML -Code of the module before inserting it into the main website template. There are several predefined chrome-styles (Table, Horz, Xhtml, Rounded, Outline), but not always what is suitable for solving current tasks.
To determine your own display style in the template, you need to create a "modules.php" file in the "HTML" directory. That is, for the template named "My_Template", the file should be placed here - "templates / my_template / html / modules.php".
In this file, you must define a function called "modchrome_style" where Style is your name of your style. This feature will take three arguments - $ Module, & $ Params and & $ ATTRIBS as shown below:
function Modchrome_Style ($ Module, & $ Params, & $ ATTRIBS) (/ * Processing and output of the HTML code of the module * /)
In this feature, you can use any PHP code, as well as all the parameters of the module itself, its properties and any data stored in the Joomla database will also be available. Mostly there are only the following
- $ Module-\u003e Content - Content of the module itself, direct HTML code.
- $ Module-\u003e Title - the name of the module specified in the control panel in the module manager.
- $ Module-\u003e Showtitle - flag, show the name or not (True or False).
The modchrome_style function is an ordinary php function, you can use absolutely any PHP code here. Below is an example if the title display is turned on in the module settings, the header text is displayed before the content of the module.
function Modchrome_Style ($ Module, & $ Params, & $ ATTRIBS) (IF ($ Module-\u003e Showtitle) (Echo "
"$ Module-\u003e Title."
";) Echo $ Module-\u003e Content;)
It is possible to refer to any parameters of the module. For example, the variance of the class module
You can also add your attributes that are used in Chrome into the position code. To do this in the position tag Add your own attributes. The names of additional attributes can be specified arbitrary, they will all be transmitted to the $ attribs associative array.
Practical example Chrome functions:
function Modchrome_custom ($ Module, $ Params, $ ATTRIBS) (IF (ISSET ($ ATTRIBS ["Headerlevel \u003d $ ATTRIBS [" Headerlevel "];) ELSE ($ Headerlevel \u003d 3;) if (ISSET ($ attribs ["background"])) ($ background \u003d $ attribs ["background"];) else ($ background \u003d "blue";) echo "
"; if ($ Module-\u003e Showtitle) (Echo" "$ Module-\u003e Title." ";) Echo" "; Echo $ Module-\u003e Content; Echo""; Echo"";
}
Practical examples of using the "MODCHROME_CUSTOM" function
One of the most important advantages of PHP is how it works with HTML forms. Here the main thing is that each element of the form automatically becomes available to your PHP programs. For detailed information on the use of forms in PHP, read the section. Here is an example of an HTML form:
Example # 1 simple HTML form
In this form there is nothing special. This is an ordinary HTML form without any special tags. When the user fills the form and press the send button, the Action.php page will be called. This file may be something like:
Example # 2 Display these forms
Hello,
.
You years.
An example of the output of this program:
Hello, Sergey. You are 30 years old.
If you do not take into account the pieces of code with hTMLSPECIALCHARS ()
and (int)The principle of operation of this code should be simple and understandable. hTMLSPECIALCHARS ()
Provides the correct encoding of "special" HTML characters so that malicious HTML or JavaScript is inserted into your page. The age field about which we know that it should be a number we can just transform in integer
that automatically relieves us from unwanted characters. PHP can also do it automatically by expansion filter. . Variables $ _Post ["Name"] and $ _Post ["Age"] Automatically installed for you with PHP. Earlier we used a superglobal variable $ _Server. here we also use the superglobal variable $ _Post. which contains all POST data. notice, that send method (Method) Our form is POST. If we used the method Get.then the information of our form would be in a superglobal variable $ _Get. . In addition, you can use a variable $ _Request. If the data source does not matter. This variable contains a mixture of data GET, POST, COOKIE.
15 YEARS AGO.
According to the HTTP Specification, You SHOULD USE THE POST METHOD WHEN YOU "RE USING THE FORM TO CHANGE THE STATE OF SOMETHING ON THE SERVER END. FOR EXLOW, IF A Page HAS A FORM TO ALLOW TO ALLOV TO Add their Own Comments, Like this Page Here, The Form Should Use POST. If you click "Reload" Or "refresh" on a post, it "s Almost Always An Error - You Shouldn" T Be Posting the Same Comment Twice - Which is Why These Pages Arena "t Bookmarked or Cached.
You Should Use The Get Method WHEN YOUR FORM IS, WELL, Getting Something Off The Server and Not Actually Changing Anything. For example, The Form for A Search Engine Should Use Get Be Changing Anything That The Client Might Care Anything, And Bookmarking Or Caching The Results Of A Search-Engine Query Is Just As Useful AS Bookmarking or Caching A STATIC HTML PAGE.
2 Years Ago.
Worth Clarifying:
POST IS NOT MORE SECURE THAN GET.
The Reasons for Choosing Get VS Post Involve Various Factors SUCH AS INTENT OF THE REQUEST (ARE LIMITS TO HOW LONG A URL CAN BE, AND GET PARAMETERS A SENT IN THE URL), and How Easily You Want The Action to Be Shareable - Example, Google Search Ire Get Because It Makes It Easy to Copy and Share The Search Query With Someone Else Simply by Sharing The URL.
Security Is Only A Consideration Here Due To the Fact That a Get Is Easier to Share Than A Post. Example: You don "T Want A Password to Be Sent by Get, Because the user Might Share The ReSulting Url and Inadvertently Expose Their Password.
HOWEVER, A GET AND A POST AER EQUALLY EASY TO INTERCEPT by A Well-Placed Malicious Person If You Don "T Deploy TLS / SSL to Protect The Network Connection Itself.
All Forms Sent Over Http (Usally Port 80) Are Insecure, And Today (2017), There Arena "T Many Good ReaSons for a Public Website to Not Be using HTTPS (Which is basicly HTTP + Transport Layer Security).
AS A BONUS, IF You Use TLS You Minimise The Risk of Your Users Getting Code (ADS) Injected Into Your Traffic That Wasn "T Put There By You.
fUNCTION MODCHROME_MODBOX ($ Module, & $ Params, & $ ATTRIBS) // Call a function
{
if (! Empty ($ module-\u003e content)): / * Check the presence in the search for the included module * /?\u003e
title; / * Display the title * /?\u003e
content; / * Display the contents of the module * /?\u003e
}
?\u003e Ready. Now you only need to specify it as an output style.
EM element is an excerpt of text with an emphasized accent. You can use it to draw the reader's attention to the meaning of the proposal or paragraph. I will tell you that it means, after which the EM element is described.
Table 8-6: Em element
Figure 8-3: Using EM element
In this example, I put the focus on I (I) at the beginning of the sentence. If you think about EM element, then when you pronounce a sentence, we consider the question that this offer is a response to the question. For example, imagine that I asked: "Who loves apples and oranges?" Your answer will be: "I love apples and oranges." (When you pronounce it out loud and put the focus on me, you give to understand that you are a person who loves these fruits).
But if I asked: "Do you like apples and what else?" You could answer: "I love apples and oranges (Oranges)." In this case, the emphasis will be made on the last word, emphasizing that oranges are another fruit you like. This option in HTML would look like this:
I Like Apples and oranges. .
Determination of foreign words and technical terms
The element I denotes a part of the text that has a different nature than the surrounding content. This is a rather vague definition, but general examples include words from other languages, technical or scientific terms and even human thoughts (in contrast to speech). The element I described.
Table 8-7: Element I.
Figure 8-5: Using the element S.
![](https://i2.wp.com/storage.smarly.net/html5/8.5.png)
Defining an important text
The Strong element denotes the text excerpt that is important. The in describes this item.
Table 8-9: Element strong
Figure 8-7: Using the Element U.
![](https://i2.wp.com/storage.smarly.net/html5/8.7.png)
Adding a small font
The small element indicates a small font and is often used for reservations and clarifications. The Small element is presented.
Table 8-11: Small element
Figure 8-8: Using the small element
![](https://i2.wp.com/storage.smarly.net/html5/8.8.png)
Adding upper and lower index
You can use the elements of SUB and SUP to indicate the upper and lower index, respectively. Upper indexes are used to write words in some languages, and both, upper and lower indices are used in simple mathematical expressions. These elements are presented.
Table 8-12: Elements sub and sup
Figure 8-9: Use sub and sup elements
![](https://i0.wp.com/storage.smarly.net/html5/8.9.png)
Chrome is the final processing of the HTML -Code of the module before inserting it into the main website template. There are several predefined chrome-styles (Table, Horz, Xhtml, Rounded, Outline), but not always what is suitable for solving current tasks.
To determine your own display style in the template, you need to create a "modules.php" file in the "HTML" directory. That is, for the template named "My_Template", the file should be placed here - "templates / my_template / html / modules.php".
In this file, you must define a function called "modchrome_style" where Style is your name of your style. This feature will take three arguments - $ Module, & $ Params and & $ ATTRIBS as shown below:
function Modchrome_Style ($ Module, & $ Params, & $ ATTRIBS) (/ * Processing and output of the HTML code of the module * /)
In this feature, you can use any PHP code, as well as all the parameters of the module itself, its properties and any data stored in the Joomla database will also be available. Mostly there are only the following
- $ Module-\u003e Content - Content of the module itself, direct HTML code.
- $ Module-\u003e Title - the name of the module specified in the control panel in the module manager.
- $ Module-\u003e Showtitle - flag, show the name or not (True or False).
The modchrome_style function is an ordinary php function, you can use absolutely any PHP code here. Below is an example if the title display is turned on in the module settings, the header text is displayed before the content of the module.
function Modchrome_Style ($ Module, & $ Params, & $ ATTRIBS) (IF ($ Module-\u003e Showtitle) (Echo "
"$ Module-\u003e Title."
";) Echo $ Module-\u003e Content;)It is possible to refer to any parameters of the module. For example, the variance of the class module
You can also add your attributes that are used in Chrome into the position code. To do this in the position tag
Practical example Chrome functions:
function Modchrome_custom ($ Module, $ Params, $ ATTRIBS) (IF (ISSET ($ ATTRIBS ["Headerlevel \u003d $ ATTRIBS [" Headerlevel "];) ELSE ($ Headerlevel \u003d 3;) if (ISSET ($ attribs ["background"])) ($ background \u003d $ attribs ["background"];) else ($ background \u003d "blue";) echo "
Practical examples of using the "MODCHROME_CUSTOM" function
One of the most important advantages of PHP is how it works with HTML forms. Here the main thing is that each element of the form automatically becomes available to your PHP programs. For detailed information on the use of forms in PHP, read the section. Here is an example of an HTML form:
Example # 1 simple HTML form
In this form there is nothing special. This is an ordinary HTML form without any special tags. When the user fills the form and press the send button, the Action.php page will be called. This file may be something like:
Example # 2 Display these forms
Hello,
.
You years.
An example of the output of this program:
Hello, Sergey. You are 30 years old.
If you do not take into account the pieces of code with hTMLSPECIALCHARS () and (int)The principle of operation of this code should be simple and understandable. hTMLSPECIALCHARS () Provides the correct encoding of "special" HTML characters so that malicious HTML or JavaScript is inserted into your page. The age field about which we know that it should be a number we can just transform in integer that automatically relieves us from unwanted characters. PHP can also do it automatically by expansion filter. . Variables $ _Post ["Name"] and $ _Post ["Age"] Automatically installed for you with PHP. Earlier we used a superglobal variable $ _Server. here we also use the superglobal variable $ _Post. which contains all POST data. notice, that send method (Method) Our form is POST. If we used the method Get.then the information of our form would be in a superglobal variable $ _Get. . In addition, you can use a variable $ _Request. If the data source does not matter. This variable contains a mixture of data GET, POST, COOKIE.
15 YEARS AGO.
According to the HTTP Specification, You SHOULD USE THE POST METHOD WHEN YOU "RE USING THE FORM TO CHANGE THE STATE OF SOMETHING ON THE SERVER END. FOR EXLOW, IF A Page HAS A FORM TO ALLOW TO ALLOV TO Add their Own Comments, Like this Page Here, The Form Should Use POST. If you click "Reload" Or "refresh" on a post, it "s Almost Always An Error - You Shouldn" T Be Posting the Same Comment Twice - Which is Why These Pages Arena "t Bookmarked or Cached.
You Should Use The Get Method WHEN YOUR FORM IS, WELL, Getting Something Off The Server and Not Actually Changing Anything. For example, The Form for A Search Engine Should Use Get Be Changing Anything That The Client Might Care Anything, And Bookmarking Or Caching The Results Of A Search-Engine Query Is Just As Useful AS Bookmarking or Caching A STATIC HTML PAGE.
2 Years Ago.
Worth Clarifying:
POST IS NOT MORE SECURE THAN GET.
The Reasons for Choosing Get VS Post Involve Various Factors SUCH AS INTENT OF THE REQUEST (ARE LIMITS TO HOW LONG A URL CAN BE, AND GET PARAMETERS A SENT IN THE URL), and How Easily You Want The Action to Be Shareable - Example, Google Search Ire Get Because It Makes It Easy to Copy and Share The Search Query With Someone Else Simply by Sharing The URL.
Security Is Only A Consideration Here Due To the Fact That a Get Is Easier to Share Than A Post. Example: You don "T Want A Password to Be Sent by Get, Because the user Might Share The ReSulting Url and Inadvertently Expose Their Password.
HOWEVER, A GET AND A POST AER EQUALLY EASY TO INTERCEPT by A Well-Placed Malicious Person If You Don "T Deploy TLS / SSL to Protect The Network Connection Itself.
All Forms Sent Over Http (Usally Port 80) Are Insecure, And Today (2017), There Arena "T Many Good ReaSons for a Public Website to Not Be using HTTPS (Which is basicly HTTP + Transport Layer Security).
AS A BONUS, IF You Use TLS You Minimise The Risk of Your Users Getting Code (ADS) Injected Into Your Traffic That Wasn "T Put There By You.