In the thinkphp template, the loop array does not loop out the required data. I wrote an array in the config. php project configuration file, and the code
/* Navigation on the left side of the website */'menu '=> array ('headnav' => 'control panel ', 'subnav' => array ('name' => 'system settings', 'menumark' => 'system', 'URL' => 'System/index '), array ('name' => 'navigation management', 'numark' => 'Nav', 'URL' => 'Nav/navlist '), array ('name' => 'ad image', 'numark' => 'Show', 'URL' => 'Show/showlist '), array ('name' => 'administrative list', 'numark' => 'admin', 'URL' => 'admin/adminlist '),),),
The code in the template is as follows:
{$v.headnav}
Depressed, I have previously written another framework that can be used, but it cannot be transplanted to thinkphp.
Reply to discussion (solution)
In foreach, how did you get the menu value...
Config. the array written in php needs to be obtained using the C () method when used. in the controller, you first $ this-> assign ('menu ', C ('menu '); then traverse it
Config. the array written in php needs to be obtained using the C () method when used. in the controller, you first $ this-> assign ('menu ', C ('menu '); then traverse it
I assigned a value in the public controller and can print it out.
You have mistaken the circular object. the modified code is as follows:
{$menu["headnav"]}
You have mistaken the circular object. the modified code is as follows:
{$menu["headnav"]}
This does not seem to be true. the next-level array cannot be obtained.
Replace the volist label with the foreach label.
{$v2.name}
Replace the volist label with the foreach label.
{$v2.name}
This has nothing to do with the loop tag. the original writing method is correct and has something to do with the defined array. as a result, only one group of arrays can be cyclically generated.
The correct array definition in config. php should be like this:
/* Navigation on the left side of the website */'menu '=> array ('menu [1]' => array ('headnav' => 'control panel ', 'subnav' => array ('name' => 'website settings', 'menumark' => 'system', 'URL' => 'System/index '), array ('name' => 'navigation management', 'numark' => 'Nav', 'URL' => 'Nav/navlist '), array ('name' => 'ad management', 'numark' => 'Show', 'URL' => 'Show/showlist '), array ('name' => 'management list', 'numark' => 'admin', 'URL' => 'admin/adminlist '),)), 'menu [2] '=> array ('headnav' => 'single page management', 'subnav' => array ('name' => 'single page management ', 'numark' => 'Page', 'URL' => 'Page/pagelist '),)),),
Modify the array configuration. the template's cyclic tag is correct.
The correct array definition in config. php should be like this:
/* Navigation on the left side of the website */'menu '=> array ('menu [1]' => array ('headnav' => 'control panel ', 'subnav' => array ('name' => 'website settings', 'menumark' => 'system', 'URL' => 'System/index '), array ('name' => 'navigation management', 'numark' => 'Nav', 'URL' => 'Nav/navlist '), array ('name' => 'ad management', 'numark' => 'Show', 'URL' => 'Show/showlist '), array ('name' => 'management list', 'numark' => 'admin', 'URL' => 'admin/adminlist '),)), 'menu [2] '=> array ('headnav' => 'single page management', 'subnav' => array ('name' => 'single page management ', 'numark' => 'Page', 'URL' => 'Page/pagelist '),)),),
Modify the array configuration. the template's cyclic tag is correct.
......
Misakaqunianx... is there any problem?
The correct array definition in config. php should be like this:
/* Navigation on the left side of the website */'menu '=> array ('menu [1]' => array ('headnav' => 'control panel ', 'subnav' => array ('name' => 'website settings', 'menumark' => 'system', 'URL' => 'System/index '), array ('name' => 'navigation management', 'numark' => 'Nav', 'URL' => 'Nav/navlist '), array ('name' => 'ad management', 'numark' => 'Show', 'URL' => 'Show/showlist '), array ('name' => 'management list', 'numark' => 'admin', 'URL' => 'admin/adminlist '),)), 'menu [2] '=> array ('headnav' => 'single page management', 'subnav' => array ('name' => 'single page management ', 'numark' => 'Page', 'URL' => 'Page/pagelist '),)),),
Modify the array configuration. the template's cyclic tag is correct.
I changed this method. the array loops out. thank you!