Jump to content

Invalid arguments supplied for foreach


Recommended Posts

Hello, i want to ask, i maintain a website that using a processwire and php, and i want to make an archive at my website using a subfolder system, but when i try,
the sebfolder is show but when i click the files in that subfolder not show, and my browser just show me an error Invalid argument supplied for foreach(), i don't know why it error

Here i attach my code and my screenshoot website :

This is my code


This is result of my website


This is my error




Link to comment
Share on other sites

I think your selector should be:

foreach($pages->get("/files/")->children as $folder) {

// code for the first iteration, you are now inside the folder

  foreach($folder->files as $lagu) {

  // here you are iterating on the files



Link to comment
Share on other sites

I have been try your sugestion but it doesn't work either, because i have page in another page, when i try your sugest, the page didn;t show, but file is show, what i'm trying to make is a subfolder system. Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...