Hey all,

Am working with anothers script on a Wordpress plugin.

There is a menu added to one page in the admin area of the plugin using this:

  <div class="menu-cat">
        <h2>select category</h2>
            <div class='submenu' >
                <a href="<?= $curaddress ?>" >home</a>
            </div>
<? 

foreach($cat as $n=>$c):
    echo "
            <h3>{$c['info']->name}</h3>
";

    foreach ( $c['list'] as $k => $r ):
        $sub = omegaid($r->id);
      echo "
                <div class='submenu' >
                    <a href='{$curaddress}&task=listing&sub={$sub}' >{$r->name}</a>
                </div>
        ";
    endforeach;
    endforeach;




?>  
        <div class='clr clear ' ></div>
    </div>

These two are being called in the beginning of the page:

$curaddress = get_curaddress();
$curaddress = get_urlpath('task');

This works great on it's current page displaying the menu brilliantly but when I tried to add it to another page for the plugin admin I get a "Warning: Invalid argument supplied for foreach()" on both foreach arguments. *I take out the first one to see if the second would fire and still get the error.

Now, after messing around with this for a bit I just copied EVERYTHING from the working page and pasted over EVERYTHING in the page I want the menu to work on. I still get errors.

I would think that it should work here since it works perfect on the other page. What in the heck am I missing here? Is there a rule where I can only use a specific foreach argument once?

Any help at all would be greatly appreciated..

Recommended Answers

All 3 Replies

I am not sure, but I would try looking at the varables being passed to the loops. Check to see if they are declared before the loop is called with a echo statment. If not there is your problem. Sorry I couldn't be of more help.

Hey Travus, thanks for the quick attempt here. This makes great sense but since it works for one page, shouldn't it work for the other? All neccessary files (includes) match the working page. In fact, everything mathes the working page only using a different page name. Working page = items_listing.php and Wanted page = items_multiple_upload.php. Just can't understand what is missing here...is there some URL preference for the script here?

There might be something to do with the url name. I am not fimilar with the script as a whole so I cant say for sure. Echo the variables before the loops start to see what comes up.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.