Webman-framework

Lightweight, Component-based, and Database-oriented Web Application Framework

About | Overview | Documentation

 

Documentation > Modules and APIs > TLD_HTML_Map

TLD_HTML_Map

 

Description:

The core module used to display the content data of Table_List_Data module's instance following Webman-framework's view template system structure standard.

This module has been used inside the following Webman-framework's component type modules: webman_db_item_view_dynamic, webman_text2db_map, webman_TLD_item_view, webman_calendar, webman_calendar_interactive, webman_calendar_week_list, webman_calendar_weekly, and webman_calendar_weekly_timerow.

 

Dependencies:

Webman-framework's Core Modules:

  • Table_List_Data (Aggregation)

 

1. View Template

The paired template tags <!-- start_list_ name=tld_items //--> and <!-- end_list_ //--> are used to mark the parts of LIST template-element (lines 14-21) to be processed by TLD_HTML_Map instance. The word pattern $tld_num_ is used to map special column name "num" that represents Table_List_Data's item numbers. Other column names are mapped using template word patterns $tld_column_name_1_, ..., till $tld_column_name_n_, adhere mapping naming convention imposed by TLD_HTML_Map module itself.

  1 <html>                                 
  2 <body>                                 
  3 <!-- start_view_ //-->                 
  4 <table border="1">                     
  5   <tr>                                 
  6     <th>Num.</th>                      
  7     <th>column_caption_1</th>          
  8     <th>column_caption_2</th>          
  9     ...                                
 10     <th>column_caption_n</th>          
 11   </tr>                                
 12                                        
 13   <!-- start_list_ name=tld_items //-->
 14   <tr >                                
 15     <td align="right">$tld_num_.</td>  
 16                                        
 17     <td>$tld_column_name_1_</td>       
 18     <td>$tld_column_name_2_</td>       
 19     ...                                
 20     <td>$tld_column_name_n_</td>       
 21   </tr>                                
 22   <!-- end_list_ //-->                 
 23 <!-- end_view_ //-->                   
 24 </body>                                
 25 </html>                                

In the context of Webman-framework's component implementation, the above LIST template-element will be passed to and processed inside process_LIST hook function (see section 4).

 
2. Instantiation and Basic Parameter Setting

The $tld argument is an instance of Table_List_Data module.


my $tldhtml = new TLD_HTML_Map;
            
$tldhtml->set_Table_List_Data($tld);


Pagination support for large number of data items can be done by passing $num_view and $num_view arguments to the next two functions.
$tldhtml->set_Items_View_Num($num_view);
$tldhtml->set_Items_Set_Num($num_set);



 
3. Processing Template Element Content

$tldhtml->set_HTML_Code($te_content);
my $content = $tldhtml->get_HTML_Code;



 
4. Implementation Inside Hook Function

sub process_LIST { 
    my $this = shift @_;
    my $te = shift @_;

    my $cgi = $this->get_CGI;
    my $dbu = $this->get_DBU;
    my $db_conn = $this->get_DB_Conn;
    
    my $te_content = $te->get_Content;
    my $te_type_num = $te->get_Type_Num;
    my $te_type_name = $te->get_Name;
    
    ### Start process template-element's content.
    if ($te_type_name eq "tld_items") {
        ### First is to create Table_List_Data instance and 
        ### add some content data into it.
        my $tld = ...
        ...
        ...
        ...
        
        ### Use TLD_HTML_Map module to display the above 
        ### $tld instance content data,
        my $tldhtml = new TLD_HTML_Map;

        $tldhtml->set_Table_List_Data($tld);

        ### Implement the next 2 lines to enable 
        ### pagination support.
        #$tldhtml->set_Items_View_Num($num_view);
        #$tldhtml->set_Items_Set_Num($num_set);
        
        $tldhtml->set_HTML_Code($te_content);
        my $content = $tldhtml->get_HTML_Code;
    }
}