In the thinkphp template, the loop array does not loop out the required data.

Source: Internet
Author: User
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}

  • {$v2.name}


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"]}
 
                 
  
  • {$v2.name}

You have mistaken the circular object. the modified code is as follows:

 
  {$menu["headnav"]}
 
                 
  
  • {$v2.name}


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!

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.