How does the mysterious array come about first: this is a problem with the output page in a template. It uses an array to output a large amount of information, including text and images.
What is puzzling is that it only uses one sentence.
To facilitate analysis, I first list the sentences in the template.
This sentence The output N many text and images are displayed on the home page. Then I found the method to call the method sentence.
The following is a big project (of course, I cannot write it all in length, because it is too long to show the key. I believe the experts will understand it at a glance)
// Section information
$ Model_web_config = Model ('web _ config ');
$ Web_html = $ model_web_config-> getWebHtml ('index ');
Tpl: output ('web _ html ', $ web_html );
The getWebHtml method is as follows:
/**
* Module html information
*
*/
Public function getWebHtml ($ web_page = 'index', $ update_all = 0 ){
$ Web_array = array ();
$ Web_list = $ this-> getWebList (array ('web _ Show' => 1, 'Web _ page' => array ('like', $ web_page. '% ')));
If (! Empty ($ web_list) & is_array ($ web_list )){
Foreach ($ web_list as $ k => $ v ){
$ Key = $ v ['web _ page'];
If ($ update_all = 1 | empty ($ v ['web _ html ']) {// query the database when the Force update or content is null
$ Web_array [$ key]. = $ this-> updateWebHtml ($ v ['web _ id'], $ v ['style _ name']);
} Else {
$ Web_array [$ key]. = $ v ['web _ html '];
}
}
}
Return $ web_array;
}
Okay, my problem is coming,
$ Output ['web _ html '] ['index']; how can we create arrays in ['web _ HTML'] and ['index, why?
Reply to discussion (solution)
Let's see how the getWebList method is written.
Or print $ web_list
You will know.
Let's see how the getWebList method is written.
Or print $ web_list
You will know.
This is $ web_list
/**
* Read record list
*
* @ Param
* @ Return array returned results in array format
*/
Public function getWebList ($ condition = array ('web _ page' => 'index'), $ page = ''){
$ Result = $ this-> table ('web')-> where ($ condition)-> order ('web _ sort ')-> page ($ page) -> select ();
Return $ result;
}
I printed the $ web_list array in the following format:
Array ([0] => Array ([web_id] => 1 [web_name] => 1F [style_name] => red [web_page] => index [update_time] => 1433752194 [web_sort] => 1 [web_show] => 1 [web_html] =>
I think like this: even if $ output ['web _ html '] ['index'] is an array, it must be a two-dimensional array, and the two-dimensional key-value relationship can be printed.
However, this is really not the case. it's strange.
Your $ web_list has such a [web_page] => index
In your code
Foreach ($ web_list as $ k => $ v ){
$ Key = $ v ['web _ page']; // isn't the value of $ key as index?
If ($ update_all = 1 | empty ($ v ['web _ html ']) {// query the database when the Force update or content is null
$ Web_array [$ key]. = $ this-> updateWebHtml ($ v ['web _ id'], $ v ['style _ name']);
} Else {
$ Web_array [$ key]. = $ v ['web _ html '];
}
}
Does $ web_array [$ key] assign values to $ web_array ['index?
*****************
Is this working? it's like a template tag or something. Check whether the template system has any special processing for this tag ..