(Refer to related articles on the web, test reviews, the following methods test success) 1: Add the page module to be displayed on the page <div class= "left" area= "Bottom_foot" widget_type= "area" > <!--{ Widgets Page=index area=bottom_foot}--></div>2: Modify the project directory under/data/page_config/ default.index.config.php to add information about the module (
modifying a page profile directly is not a good way to do it) ' Widgets ' => ... Array ( ' _widget_1000 ' => Array ( ' name ' = ' Test ', ' Options ' => Array ( ' ad_image_url ' = ' data/files/mall/template /200908070207084061.gif ', ' ad_link_url ' = ', ' ), ), ), ... ' config ' => ... Array ( ' bottom_foot ' => Array ( & nbsp; 0 = ' _widget_1000 ', ),, ... 3: In the Engineering catalog External/widgets name (consistent with the name defined above) directory, and then build the file main.widget.php class Testwidget extends basewidget{ var $_name = ' Test '; function _get_data () { $test _mod =&m (' Test ');
$goods = $test _mod->getall ("select * from ecm_goods where goods_id = 1");
return $goods; } } 4: Building model Files under Includes/model (interacting with the database) class Testmodel extends basemodel{ content can copy the same file as other pendants, or is empty (not tested)} 5: Create a widget.html file in a sibling directory (the template is for presentation) <div class= "Module_common" >
Pendant Development NotesEcmall pendant development is essentially a background development of a lot of pages, respectively, to invoke the program to display these pages, to achieve the purpose of the first page content replacement, so as to reduce the follow-up development, developers only need to develop the pendant can be, as far as the location can be arbitrarily determined. (You also need to adjust the HTML, but at least the background data does not have to do) process introduction: 1:ecmall template page Call widget page (the whole process is more complex) <!--{Widgets Page=index area=cycle_image}--> Parameters: Page: Indicates the index page area: Indicates the displayed region. (equivalent to telling the program that the generated page was put there) 2: After the Ecmall template engine regenerates a temporary PHP file, the above code is parsed into such PHP code. <!--{Widgets Page=index area=cycle_image}-->
<?php $this->display_widgets (Array (' page ' = ' index ', ' area ' = ' cycle_image ');?> 3: View the source /** * view callback function for the next display_widgets () method [show small pendant] * * @author garbin * @param Array $options * @return void */ function Display_widgets ($options) { $area = isset ($options [' area '])? $options [' Area ']: '; $page = Isset ($options [' page '])? $options [' page ']: '; if (! $area | |! $page) {return; } include_once (Root_path. '/includes/widget.base.php '); /* Gets the pendant configuration information for this page */$widgets = Get_widget_config ($this->_get_template_name (), $ page); /* If there is no area */if (! isset ($widgets [' config '] [$area])) {return; } /* Displays the pendant in the area sequentially */foreach ($widgets [' config '] [$area] as $widget _id) {$widget _info = $widgets [' Widgets '] [$widget _id]; $wn = $widget _info [' name ']; $options = $widget _info [' Options ']; $widget = & Widgets ($widget _id, $wn, $options); $widget->display (); } /*** gets the name of the template currently in use * * @author garbin* @return string*/function _get_template_name () {return ' default '; } /** * Gets the specified style, specifies the configuration information for the page's pendant * * @author garbin * &nb sp; @param string $template _name * @param String $page * @return Array */function Get_widget_config ($template _name, $page)/ /default index { static $widgets = null; $key = $template _name. ‘_‘ . $page; if (!isset ($widgets [$key]) { $tmp = Array (' widgets ' = = Array (), ' config ' = = Array ()); $confi G_file = Root_path. '/data/page_config/'. $template _name. ‘.‘ . $page. '. config.php '; if (is_file ($config _file)) { /* has a profile, take it from the config file */ $tmp = include_once ($config _file); } $widgets [$key] = $tmp; } return $widgets [$key]; } /** * Get pendant instances * * @author garbin * &nbs P @param string $id * @param string $name * @param array $options * @return Object Widget */function &widget ($id, $name, $options = Array ()) { static $widgets = Null;&nbs p; if (!isset ($widgets [$id]) { $wiDget_class_path = Root_path. '/external/widgets/'. $name. '/main.widget.php '; $widget _class_name = Ucfirst ($name). ' Widget '; include_once ($widget _class_path); $widgets [$id] = new $widget _class_name ($id, $options); } return $widgets [$id]; } /** * Display * * @author garbin * @ param none * @return void */ function display () { Echo $this->get_contents (); } /** * will get the data according to the style of the template output * * @author garbin * @return string */ function get_contents () { /* Get pendant data */ $this->assign (' Widget_data ', $this->_get_data ()); /* There may be a problem */ $this->assign (' Options ', $this- >options); $this->assign (' Widget_root ', $this->widget_root); return $this->_wrap_contents ($this->fetch (' Widgets ')); }
Ecmall Pendant Development Instance One