Zen-cart development tutorial-Sidebox plug-in development

Source: Internet
Author: User

First, you need to understand what is Sidebox, and Sidebox is a content area that is displayed on the left or right. Of course, you can also open the pull status of Sidebox so that it is displayed anywhere on the webpage. You can set Sidebox by entering the Tools/Layout Boxes Controller in the background. Note that if inclusidebox is enabled, you must manually display it to the template using a piece of code. Otherwise, you will not be able to see any effect. Zen-cart comes with many sideboxes. For example, it displays the Sidebox of the product category, the Sidebox of the latest product, and the Sidebox of the language.

  1. Sidebox-related files and directories

    Output The sidebox file on the left:/includes/modules/column_left.php

    Output The sidebox file on the right:/includes/modules/column_right.php

    Output inclusidebox file:/includes/modules/column_single.php

     

    Storage location of sidebox:/includes/modules/sideboxes

    Sidebox template location:/includes/templates/template_default/sideboxes

     

    Default left-side sidebox template/includes/templates/template_default/common/tpl_box_default_left.php

    Default sidebox template on the right:/includes/templates/template_default/common/tpl_box_default_right.php

    Default inclusidebox template:/includes/templates/template_default/common/tpl_box_default_single.php

  2. Example: hello_sidebox Development
    Next we will develop a simple sidebox to illustrate the basic steps for developing a Sidebox. This sidebox only displays a piece of text and does not implement any function. We will name this sizebox hello_sidebox.
    1) set the language and content to be displayed in sidebox
    Create a PHP file named "hello_sidebox.php" in the directory "/DES/ages/english/extra_definitions" and set the Title and content of sidebox in the english environment. This file defines two constants: BOX_HEADING_HELLOW_SIDEBOX (title of sidebox) and 'box _ HEADING_HELLOW_SIDEBOX_CONTENT (displayed content). The Code is as follows: Define (BOX_HEADING_HELLOW_SIDEBOX, "Hello sidebox ");
    Define (BOX_HEADING_HELLOW_SIDEBOX_CONTENT, "This is a sidebox demo ");

    2) create a sidebox File
    Create a new file named "hello_sidebox.php" under "/includes/modules/sideboxes" and enter the following code. The first line loads the template file hello_sidebox, the second line sets the title of the sidebox, and the third line of code loads the template file used to output the sidebox.

    Require ($ template-> get_template_dir ('tpl _ wp_cats.php', DIR_WS_TEMPLATE, $ current_page_base, 'sideboxes'). '/tpl_hello_sidebox.php ');
    $ Title = BOX_HEADING_HELLOW_SIDEBOX;
    Require ($ template-> get_template_dir ($ column_box_default, DIR_WS_TEMPLATE, $ current_page_base, 'common'). '/'. $ column_box_default );

    3) create a sidebox Template File
    The sidebox template file does not actually output any content to the webpage. Here, it only constructs the content to be displayed inside the Sidebox (variable $ content ). here, the content is only to assign the value of the constant BOX_HEADING_HELLOW_SIDEBOX_CONTENT to $ content, the Code is as follows.

    $ Content = "";
    $ Content. = BOX_HEADING_HELLOW_SIDEBOX_CONTENT;


    4) install sidebox

    Go to the management background> Tools> Layout Boxes Controller and you will see the hello_sidebox plug-in we just developed. Select hello_sidebox and click the edit button to set Left/Right Column Status to on, click the Update button to complete the installation. now, refresh the homepage to see our hello_sidebox box?

    5). Release sidebox

    Package the file according to the original directory structure, as shown in figure As shown in, even if the release is successful, we can share the developed plug-ins with others.

     

    It's easy. Although this example is simple, it also covers the basic steps for developing Sidebox. With these basics, you can develop more complex applications.

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.