Support Forum Softcomplex logo
About Us  | Services  | Download  | Order  | Support  | |
| Search | Today's Posts | Stats | Board Rules | Not logged in [ Login | Register ]
go to bottom
Last active: Never

Printable Version | Subscribe | Add to Favourites   Post new thread
Author: Subject: PHP , MySQL menu
cyberkid
Newbie

Posts: 1
Registered: 6/30/2005
Location: India
Member Is Offline
posted on 6/30/2005 at 12:31 PM Reply With Quote
PHP , MySQL menu


Hi, how to load the mysql table values as a menu item using Tigra Tree Menu.

Thanx in advance
Cyberkid
View User's Profile View All Posts By User U2U Member
mdsade
Junior Member

Posts: 4
Registered: 7/1/2005
Location: Las Vegas
Member Is Offline
posted on 7/1/2005 at 08:33 PM Reply With Quote
PHP MySQL


I wrote this a long time ago for use. Its not the cleanest code but it should work. for version 2.0
Step 1: Create a file called menu_items.php where you have your other Tigra .js file and paste the below code. Change username, password and database. Change script call in your page to point to menu_items.php insetead of .js.


Code:

<?
$link = mysql_connect('localhost', 'username', 'password')
or die('Could not connect: ' . mysql_error());
mysql_select_db('database') or die('Could not select database');

$sql = "SELECT * FROM tigra_menu ORDER BY container,sub_container1,sub_container2";
$result = mysql_query($sql);
$prev_item= array('container'=>"", 'sub_container1'=>"", 'sub_container2'=>"");
$pri=0;$sec=0;
echo "var MENU_ITEMS = [\n";
while ($menu_item = mysql_fetch_array($result, MYSQL_ASSOC)) {

if ($menu_item['container'] != $prev_item['container']) {
if ($sec > 0){echo "],\n";$sec=0;}
if ($pri > 0){echo "],\n";$pri=0;}
echo "['".$menu_item['container']."','".$menu_item['link']."'";
$pri=0;
}else{
if($pri==0){echo ",null,\n";$pri++;}
if ($menu_item['sub_container1'] != $prev_item['sub_container1']) {
if($sec > 0){echo " ],\n";}
$sec=0;
echo " ['".$menu_item['sub_container1']."','".$menu_item['link']."'";
$sec++;
}else{
if($sec==1){echo ",null,\n";}
$sec++;
echo " ['".$menu_item['sub_container2']."','".$menu_item['link']."'],\n";
}
$pri++;
}
$prev_item = $menu_item;
}
if($sec > 0){echo " ],\n";}
if($pri > 0){echo "],\n";}
echo "];\n";
?>


Step 2: Create table called tigra_menu. Make 5 fields (primary_key,container,sub_container1,sub_container2,link).
sub_container1 & 2 must be allowed [NULL]

Step 3: Fill in the database similar to this. Container is your top element, sub_cont1 is 2nd, and sub_container2 is last. To get a child menu you have to put the parents before it in the row.
Code:

+-------------+-----------+----------------+----------------+--------------------------------+
| primary_key | container | sub_container1 | sub_container2 | link |
+-------------+-----------+----------------+----------------+--------------------------------+
| 1 | Locations | [NULL] | [NULL] | locations/location_search.php |
| 2 | Locations | Manage | [NULL] | locations/location_manage.php |
| 3 | Locations | Manage | New | locations/location_new.php |
+-------------+-----------+----------------+----------------+--------------------------------+


Best of Luck
View User's Profile View All Posts By User U2U Member
phishee
Junior Member

Posts: 2
Registered: 9/29/2005
Member Is Offline
posted on 9/29/2005 at 11:45 PM Reply With Quote

Thanks for posting of your code. It has been quite helpful in familiarizing myself with the menu's structure.

One quick question: Is there a PHP interface or builder (that you or Tigra's developers have coded) which I could use to construct the menu and store the parameters in MySQL as you have shown?

Thanks in advance,

phishee
View User's Profile View All Posts By User U2U Member
mdsade
Junior Member

Posts: 4
Registered: 7/1/2005
Location: Las Vegas
Member Is Offline
posted on 9/30/2005 at 05:50 PM Reply With Quote

To quickly answer your question, I have not built one.

If your talking about an interface for putting the menu entries(links) into the database. I normally just manually created or altered them during the installation/upgrade of my php application. Also I had extra fields in the "tigra_menu" table for setting parameters such as privledges (wether or not the link would display for the user). No need for an interface to make quick adjustments since adjustments were rarely done.

If your talking about an interface to change the layout of the menu such as fonts and sizes and such, I found the construction of the menu to be very rigid and not easily adaptable for this type of design. As an example I changed the font on the menu. Since there was a size difference in the display of the fonts it actually became larger than the cell in which it was typed and looked ugly so I had to adjust the size of the cell then adjust the positioning of the submenu. It was a horrid undertaking. I would say design some style sheets with predefined characteristics and let the user change between the templates if they want a different look/ feel. Even some of the seemingly smallest changes will quickly distort the display.
Maybe the newer versions are better adapted for this, but the version I used was not. As a person that uses stylesheet design I found this very unforgiving in some areas.
View User's Profile View All Posts By User U2U Member
phishee
Junior Member

Posts: 2
Registered: 9/29/2005
Member Is Offline
posted on 9/30/2005 at 06:28 PM Reply With Quote

Thanks for taking the time to respond to my question. I am referring to the menu contents itself. I want our novice end-users to be able to build / edit a menu at any time and not be overwhelmed with the task. Thus, a suitable interface would be perfect. I have not played with the menu's styling but I am sure we'd disallow its tinkering from the user.

Thanks again for your help - It appears I may have to code the interface and see how it works out -

Phishee
View User's Profile View All Posts By User U2U Member
uk6451
Newbie

Posts: 1
Registered: 12/9/2005
Member Is Offline
posted on 12/9/2005 at 03:08 PM Reply With Quote

mdsade (or anyone else),

how i'm going to do exactly the same as u do (php,mysql) if i'm using the free version?

thank you.
View User's Profile View All Posts By User U2U Member
mdsade
Junior Member

Posts: 4
Registered: 7/1/2005
Location: Las Vegas
Member Is Offline
posted on 12/11/2005 at 09:52 AM Reply With Quote

I developed that for the free version. Give it a try. Unless the free version has changed in the last year or so it should work.
View User's Profile View All Posts By User U2U Member
MaxxFusion
Junior Member

Posts: 2
Registered: 1/13/2006
Location: Cleveland, OH
Member Is Offline
posted on 1/13/2006 at 07:03 PM Reply With Quote

Is anyone pulling info from an existing table? I want to be able to dynamically create the menu from my categories table. That way when I add a new categorey to my store it gets added to the menu.
View User's Profile View All Posts By User U2U Member
Post new thread

Related Links:
Tigra Tree Menu
Product Demonstrations Live Demos:
Frames targeting
Win help style
Free Download Free Download
Free Download Menu Builders
Online Builder
Product Documentation Documentation:
Documenation Page
Support Forum Technical Support
Support Forum
   
Tigra Tree Menu PRO
Product Demonstrations Live Demos
Multiple Trees
Frames Targeting
Icons and Styles Overloading
Event Handling
Performance Test
Version 1.2 features
Product Documentation Documentation
Documenation Page
Change Log
Support Forum Technical Support
Support Forum
Customer Care System
Order Now ORDER NOW!
Add to Cart
View Cart
 

Go To Top


Powered by XMB 1.9.1 Nexus
Developed By Aventure Media & The XMB Group © 2002-2004