I wrote the array in the project configuration file config.php, the code
/* Website left column navigation */' menu ' = + Array ( ' headnav ' + ' Control Panel ', ' subnav ' = ' = ' Array ( ' name ' = ' System settings ', ' Menumark ' + ' System ', ' url ' = ' system/index '), Array (' name ' = ' = ' navigation management ', ' menumark ' = ' nav ', ' url ' = ' + ' nav/ Navlist '), Array (' name ' = ' advertising image ', ' menumark ' = ' Show ', ' url ' = = ' show/showlist '), Array (' name ' = = ' Manage list ', ' Me Numark ' = ' Admin ', ' url ' = ' admin/adminlist '),),
The code inside the template is like this, as follows:
{$v. Headnav}
Depressed death personally, I have written before another framework, can be used, but transplanted to thinkphp will not be.
Reply to discussion (solution)
foreach inside the value of the menu you are how to come ...
Config.php inside the array to be used, you need to use the C () method to obtain, you in the controller first $this->assign (' Menu ', C (' menu '));
Config.php inside the array to be used, you need to use the C () method to obtain, you in the controller first $this->assign (' Menu ', C (' menu '));
I've assigned a value in the public controller, and I can print it out.
You made a mistake with the loop object, the modified part of the code is referenced below:
{$menu ["Headnav"]}
You made a mistake with the loop object, the modified part of the code is referenced below:
{$menu ["Headnav"]}
This doesn't seem to be the right thing to do with the next level array.
Replace the Volist label with a foreach label.
{$v 2.name}
Replace the Volist label with a foreach label.
{$v 2.name}
This is not the same as the loop label, landlord original writing is not wrong, is related to the definition of the array, according to this can only loop out a set of arrays.
The correct definition of an array in config.php should look like this:
/* On the left side of the site navigation */' menu ' = + Array (' menu[1] ' = = Array ( ' headnav ' + ' Control Panel ', ' subnav ' = + Array ( Array (' name ' = ' = ' Site Settings ', ' menumark ' = ' System ', ' url ' = ' system/index '), Array (' name ' = ' = ' navigation management ', ' Menuma RK ' + ' Nav ', ' url ' = ' + ' nav/navlist '), Array (' name ' = ' + ' ad management ', ' menumark ' = ' Show ', ' url ' = = ' Show/sho Wlist '), Array (' name ' = = ' management list ', ' Menumark ' + ' admin ', ' url ' = = ' admin/adminlist '),), ' menu[2] ' => ; Array ( ' headnav ' + ' single page management ', ' subnav ' = = Array ( ' name ' = ' + ' single page Management ', ' menumark ' = ' ' page ', ' url ' = ' page/pagelist '),),
Change the configuration array so that the template's loop label is correct.
The correct definition of an array in config.php should look like this:
/* On the left side of the site navigation */' menu ' = + Array (' menu[1] ' = = Array ( ' headnav ' + ' Control Panel ', ' subnav ' = + Array ( Array (' name ' = ' = ' Site Settings ', ' menumark ' = ' System ', ' url ' = ' system/index '), Array (' name ' = ' = ' navigation management ', ' Menuma RK ' + ' Nav ', ' url ' = ' + ' nav/navlist '), Array (' name ' = ' + ' ad management ', ' menumark ' = ' Show ', ' url ' = = ' Show/sho Wlist '), Array (' name ' = = ' management list ', ' Menumark ' + ' admin ', ' url ' = = ' admin/adminlist '),), ' menu[2] ' => ; Array ( ' headnav ' + ' single page management ', ' subnav ' = = Array ( ' name ' = ' + ' single page Management ', ' menumark ' = ' ' page ', ' url ' = ' page/pagelist '),),
Change the configuration array so that the template's loop label is correct.
。。。。。。
Misakaqunianx ... What's the problem with this?
The correct definition of an array in config.php should look like this:
/* On the left side of the site navigation */' menu ' = + Array (' menu[1] ' = = Array ( ' headnav ' + ' Control Panel ', ' subnav ' = + Array ( Array (' name ' = ' = ' Site Settings ', ' menumark ' = ' System ', ' url ' = ' system/index '), Array (' name ' = ' = ' navigation management ', ' Menuma RK ' + ' Nav ', ' url ' = ' + ' nav/navlist '), Array (' name ' = ' + ' ad management ', ' menumark ' = ' Show ', ' url ' = = ' Show/sho Wlist '), Array (' name ' = = ' management list ', ' Menumark ' + ' admin ', ' url ' = = ' admin/adminlist '),), ' menu[2] ' => ; Array ( ' headnav ' + ' single page management ', ' subnav ' = = Array ( ' name ' = ' + ' single page Management ', ' menumark ' = ' ' page ', ' url ' = ' page/pagelist '),),
Change the configuration array so that the template's loop label is correct.
I changed the method to the next no problem, the array loop out, thank you!