How to Create a module in Zen-cart

Source: Internet
Author: User
Although there are related modules in the left and right columns of Zen-cart in sideboxes, sometimes the contents of these boxes need to be separately displayed somewhere on the page. For example, I want to display shopping cart and currencies in the header of the page. At this time, the module provided by Zen-cart cannot be used directly. The content can be displayed freely only when the existing module is modified.
The template technology used by Zen-cart 1.3.8 is quite special. The module files in/Includes/modules are stored to generate page data, while the template files are stored in the template directories, process page content generation. The entire process is more like a hack to Zen-cart, rather than a module.
The following describes how to create a page module by creating currencies in the page header. The effect after the module is created is as follows:

Reference and comparison
/Includes/templates/template_default/sideboxes/tpl_search_header.php/Includes/templates/template_default/sideboxes/tpl_search.php

And
/Shortdes/modules/sideboxes/search_header.php/shortdes/modules/sideboxes/search. php

to get inspiration.
follow these three steps to create the module:
1) create a file named currencies_header.php in the/Includes/modules/sideboxes directory.
if necessary, you can directly operate the database using the methods provided by/Includes/modules/sideboxes/search_header.php in this file.
here, we use the/Includes/modules/sideboxes/currencies. PHP to create files, mainly to currencies. delete the sentence used for sidebox display in PHP:
$ Title = ' '. box_heading_currencies. ''; $ title_link = false; require ($ template-> get_template_dir ($ column_box_default, dir_ws_template, $ current_page_base, 'common '). '/'. $ column_box_default);

In this way, we will not call the related statements used in sidebox when calling this module.
Similarly, in this file, we can add all the elements required for a module to generate data as needed.
2) create a new file named tpl_currencies_header.php to/schemdes/templates/yourtemplate/sideboxes and create a separate display style for this module. Here, based on the location you need to place, the CSS/XHTMLCodeMake changes. The data used for display is the global variable passed in from the module in the first step.
Note: In zen-cart 1.3.8, $ content is used to store the generated page display code.
3) In the/shortdes/templates/yourtemplate/common folder, add related display generation statements to the specified page template.
In this example, to display the currencies display box on the top, you need to add this section in tpl_header.php to call the module to generate data:
<? PHP require (dir_ws_modules. 'sideboxes/currencies_header.php '); echo $ content;?>

With the above method, you can not only modify the existing module, but also create more modules as needed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.