brendon2020
[H]ard|Gawd
- Joined
- Dec 15, 2002
- Messages
- 1,541
I'm busy trying to code a dynamic menu based off of the tiger true menu,
http://www.softcomplex.com/products/tigra_tree_menu/
Basically you have to edit a js file(which i've renamed to .php so i can call php functions) in this format
['Main menu', 'link',
['Submenu', 'link',
['item1', 'link']]];
that creates a very simple menu with 1 main heading, 1 sub-main heading, and one item in the same heading.
Now i know an easy way to do this is just to put all the menu items i need in the js file, but other people need to edit it. And i need to control it, and the boss won't be happy that he has to sit and edit js files when he wants to add something to the menu
Now i've got all my headings, categories, items in a database categorized like this,
B_ID, B_Name, B_Cat, B_Cat_ID, B_Cat_Sub. These are the 5 fields i have, cat is short for category. B_ID is id of each menu item, B_Name is the menu title, B_Cat is the main category id for each menu, B_Cat_ID is the id for a sub menu title, and B_Cat_Sub is the id for each item in the sub menu mentioned before.
Hope i haven't confused you, cause this is where i get confused. Have i set this up correcttly?
The part i don't get is the php code to generate all this. Here is the code i have so far,
If someone could guide me in the right direction that would be great. It seems like i'm coding somewhat of a comment system like seen on stoofoo or shacknews. Thanks in advance.
http://www.softcomplex.com/products/tigra_tree_menu/
Basically you have to edit a js file(which i've renamed to .php so i can call php functions) in this format
['Main menu', 'link',
['Submenu', 'link',
['item1', 'link']]];
that creates a very simple menu with 1 main heading, 1 sub-main heading, and one item in the same heading.
Now i know an easy way to do this is just to put all the menu items i need in the js file, but other people need to edit it. And i need to control it, and the boss won't be happy that he has to sit and edit js files when he wants to add something to the menu
Now i've got all my headings, categories, items in a database categorized like this,
B_ID, B_Name, B_Cat, B_Cat_ID, B_Cat_Sub. These are the 5 fields i have, cat is short for category. B_ID is id of each menu item, B_Name is the menu title, B_Cat is the main category id for each menu, B_Cat_ID is the id for a sub menu title, and B_Cat_Sub is the id for each item in the sub menu mentioned before.
Hope i haven't confused you, cause this is where i get confused. Have i set this up correcttly?
The part i don't get is the php code to generate all this. Here is the code i have so far,
PHP:
echo "var TREE_ITEMS = [\n['Behaviors', 'null',\n";
$Array = array("0" => "None Selected",
"1" => "Menu1 ",
"2" => "Menu2",
"3" => "Menu3",
"4" => "Menu4",
"5" => "Menu5",
);
for ($i=0; $i<=count($Array); $i++)
{
$SQL = mysql_query("SELECT * FROM `behaviordatanew` WHERE B_Cat='$i' AND B_Cat_ID='0' AND B_Cat_Sub='0'")
or die("Coudlnt' select data: " . mysql_error());
$array = array();
while ($SQLData = mysql_fetch_array($SQL))
{
echo "['$SQLData[1]', 'null',\n";
$CatID = $SQLData[3];
$GetSubCats = mysql_query("SELECT * FROM `behaviordatanew` WHERE B_Cat='$Cat' AND B_Cat_ID='$i'")
or die("Couldnt' select data:" . mysql_error());
$GetSubCatsData = mysql_fetch_array($GetSubCats);
echo "['$SQLData[1]', 'null'],\n";
echo "],";
}
}
echo "]];";
If someone could guide me in the right direction that would be great. It seems like i'm coding somewhat of a comment system like seen on stoofoo or shacknews. Thanks in advance.