Using the functions that I have written (which use regular expressions and the preg family of functions), inserting a top level menu to be second in the list, the code would look like this: (note: I've ommitted most error checking for the sake of brevity)
Code: Select all
$filename="menus/{$_POST["menu_to_edit"]}";
$menutext=read_menu_file($filename);
$newmenu=insert_menu_item($menutext,$_POST["new_menu_order"],$_POST["new_menu_name"],$_POST["new_link"],$image_file,$mouseover_image_file);
//$image_file & $mouseover_image_file have been added to from
//the $_POST values to include the image page
if(!output_menu_file($newmenu,$filename))
{
site_error("Failed to update menu");
}
else
{
site_ok("Menu updated");
}The utility is using the Smarty template engine (Don't know how I survived before I started using that
e.g. The code for a new menu item(my smarty delimiters are {%% & %%} - I like them)
Code: Select all
function new_menuitem(menutype)
{
if (confirm('Are you sure you want to create a new '+menutype+' menu?'))
{
document.formsї"menueditform"].action="{%%$update_target%%}?action=new%20menu"
document.formsї"menueditform"].submit()
}
}If I replace the $_POST values with static values, fill out the form & submit (so the values from the form have no effect), the problem still occurs.
With the static values still in place, if I type out the URL: http://my_server/menutest/update_menu.php?action=new%20menu , (rather than submitting the form), then everything works correctly. Only one menu item is inserted into the file.
Is that strange or what?
Obviously, some of you guys would want to see other bits of code in order to comment, but I didn't want to overface everyone with loads of code straight away.
Does anyone have any ideas?? This wasn't a big utility - and at this rate it's easier to edit the menu manually (but for the intended users, that really isn't an option), but I'm starting to loose the will to live..
Any help is greatly appreaciated.
Jason.