There are four positions for modules. They are as follows:
• Column Left
• Column Right
• Content Top
• Content Bottom
The following table shows the available positions for modules in the frontend.
Choose as per your need of module position.
Status of the module
Status shows whether the module is enabled or disabled. If enabled, it is shown at the frontend, else it is not.
Sort order of the modules
If there is more than one module in any of the positions, sort order plays its role. Let us suppose two modules, Hello World and Account, are positioned to the right column of layout Account, and you like to show Hello World first, and then below it, the Account module, you have to insert Sort order 1 for Hello World and Sort order 2 for Account. If you do not insert sort order, it shows at the top. You will then be able to see the modules in the right column, as shown in the following screenshot:
Show same module in different layouts
We can easily show the same module in a different layout. To do this, click on the Add Module button and another row of the table is added; select the appropriate layout, position, status, and the sort order, then click on the Save button. You will be able to see the module in the respective layout. When you click on the Add Module button, the next row is added, as shown in the following screenshot:
Effects of clicking on the Add Module button
The Add Module button shows another row for the module setting. Open admin/ catalog/view/template/helloworld.tpl and you will see the following code, which is for the Add Module button:
<a onclick="addModule();" class="button"><?php echo
$button_add_module; ?></a>
On clicking the Add Module link, the addModule function is called; the addModule function adds a row just below the previous row.
Uninstalling the module
Navigate to admin | Extensions | Modules, and you will find the list of modules.
Just click on [Uninstall], the module gets uninstalled and all settings get deleted. Let's see how it is done. Open admin/controller/extension/module.php, you will see the public functionuninstall(),which performs the permission check and if there is permission access, it loads the model setting/extension uninstall function.
File structure – admin and frontend
When someone uses the module, it is reliable to have the admin section so that the user can handle the module functionality as well as position, layout, status, and sort order by which users can show the module wherever they like.
Creating the language files for the admin module in OpenCart
Language files are also named with MODULENAME.php. For example, let's say we want to create a file containing hello world messages or text; we have to create helloworld.php. Language files use "constant=value" configuration. The constant name is used in the code; it never changes, only the value for that language changes. If English language is active, it retrieves the constant from the English language folder's file; if another language is active, it retrieves from the other language folder's file. For example, if English language is active, the constant is taken from the English language folder's file.
$_['text_review'] = 'Product Review';
If Spanish language is active, the constant is taken from the Spanish language folder's file.
$_['text_review'] = 'De Revisión de Producto';
If German language is active, the constant is taken from the German language folder's file.
$_['text_review'] = 'ProduktBewertung';
A similar process is followed for the other languages installed.
Within the file, we will assign each line of text to a variable as $_['variablename'].
The same variable name will be used in the controller to access the text or messages. For example, in the following code:
$this->data['heading_title'] = $this->language
->get('heading_title');
Now on, we will use the heading_title controller to access the "Hello World" text.
You can see the following code at admin/language/english/module/helloworld. php.
<?php
$_['heading_title'] = 'Hello World';
$_['text_module'] = 'Modules';
$_['text_success'] = 'Success: You have modified module
Hello World!';
$_['text_content_top'] = 'Content Top';
$_['text_content_bottom'] = 'Content Bottom';
$_['text_column_left'] = 'Column Left';
$_['text_column_right'] = 'Column Right';
$_['entry_code'] = 'Hello World Content';
$_['entry_layout'] = 'Layout:';
$_['entry_position'] = 'Position:';
$_['entry_status'] = 'Status:';
$_['entry_sort_order'] = 'Sort Order:';
$_['error_permission'] = 'Warning: You do not have permission to modify module Hello World!';
$_['helloworld_content'] = Hello World Content';?>
No comments:
Post a Comment