How do I add extra style options in MySQL

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
AangepasteAuto
Advanced
Advanced
Posts: 13
Joined: Wed Jun 15, 2005 1:06 pm
Contact:

How do I add extra style options in MySQL

Post by AangepasteAuto »

Hello,

I'm trying out this menu. And I like the PHP with MySQL part alot.
I got it running so far but still has a few problems.

I have no real knowledge of PHP or SQL. I can "read" it and find the things I need to change and that's it.

I would like to use a different style sheet for the main menu then for the drop downs. I tried with adding a extra style in the database (with the number 2) and linked it to the drop down menus. But it doesn't seem to work. How do I do this?


Once I see that this menu can do what I want it to do I'll be sure to buy a license :D.

Please help me. Thank you very much
AangepasteAuto
Advanced
Advanced
Posts: 13
Joined: Wed Jun 15, 2005 1:06 pm
Contact:

Post by AangepasteAuto »

I forgot to add the link to my site if needed :oops: .

Please remember this menu doesn't look yet like it should. I'm still testing the style options :-)

http://www.aangepasteauto.nl/restyle/te ... itemap.php
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Why put it in the DB? Just add a new style in with the two other syyles you already have in your _data file. Even better, since you're calling miniStyle for your main menu just edit that one to the new look you want. The two styles you now have coded are almost exactly the same, which, of course, results in the same look in your menu system.
John
AangepasteAuto
Advanced
Advanced
Posts: 13
Joined: Wed Jun 15, 2005 1:06 pm
Contact:

Post by AangepasteAuto »

Thank you for the fast reply!

The styles are loaded from the DB. These is no _data.js file that is used.
All the files that are used are:

Code: Select all

mm_config.php
mm_phpmenu.php
milonic_src.js
mmenudom.js
mmenuns4.js
In the DB in "mm_styles" you enter the styles with a unique number for that style. For every drop down menu you have entered in "mm_menus" you set the style number.
All this generates the 2 style sheets you see.

It just doesn't add the right style to the right menu part. It keeps using the main sheet.

UPDATE: As far as I can see is the menu and the sheets made in "mm_phpmenu.php". But I don't know what to change there if needed to make more then one style sheet work. Does anyone know what to do?



The styles look almost the same :D. But on the main menu (miniStyle) I want to remove the border, shadow, etc... but it's still there so I can see it works :-). So in the end it will be different.

Hope this info helps.
AangepasteAuto
Advanced
Advanced
Posts: 13
Joined: Wed Jun 15, 2005 1:06 pm
Contact:

Post by AangepasteAuto »

I've read on the forum that http://www.Milonic.com uses the PHP MySQL version too. And they use different sheets for the main menu and the drop downs. So I know it can be done.

Has really nobody here done it? Or can nobody help me do it?

:cry: :cry:
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

Hi,

Php and mysql are kind of out of my knowledge area, however..... As I understand what Milonic does, it names the menu_data.js file as menu_data.php that way it gets parsed. I know the Milonic menu_data.php file has different styles in it. Since I don't know anything about php, maybe something else is being done to get that menu_data.php file, but I've only ever seen posts saying to rename the menu_data.js to menu_data.php [or cfm etc.]

Ruth
AangepasteAuto
Advanced
Advanced
Posts: 13
Joined: Wed Jun 15, 2005 1:06 pm
Contact:

Post by AangepasteAuto »

I know nothing about programming... but...

My guess would be that mm_phpmenu.php gets the menu from the DB?
That file has the following code.

Code: Select all

<?php


if (!mysql_pconnect($dbHost,$dbUser,$dbPasswd)) 
{
	die("Couldn't connect to the database server $MySQLServer<br><br>");
}
else
{
	mysql_select_db($dbName);
}



function runquery($query)
{
	global $adminEmail,$sendErrorReports;
	
	if (!($qry = mysql_query($query))) 
	{ 
		$hostname=gethostbyaddr($_SERVER[REMOTE_ADDR]);	
		echo "<br> MySQL Error - " . mysql_errno() . ": " . mysql_error() . "<br>"; 
		$mailbody = "
		IP Addr: $_SERVER[REMOTE_ADDR]
		Browser: $_SERVER[HTTP_USER_AGENT]
		
		Page: $_SERVER[SCRIPT_FILENAME]?$_SERVER[QUERY_STRING]
		Date: " . date("D F j, Y, G:i:s") . "
		
		Host: $hostname
		Server: $_SERVER[HTTP_HOST]
		
		Referer: $_SERVER[HTTP_REFERER]			
		
				
		MySQL Error - " . mysql_errno() . ": " . mysql_error() ."
		
		\n\n
		----------------------------------------
		Query: $query
		----------------------------------------";
		$headers = "From: datamenu1@milonic.com";
		$subject = "Milonic Data Menu Error";
		if($sendErrorReports)mail($adminEmail, $subject, $mailbody, $headers);
	}
	return $qry;
}

function doquery($query)
{
	global $adminEmail,$sendErrorReports;

	if (!($qry = mysql_query($query))) 
	{ 
		$hostname=gethostbyaddr($_SERVER['REMOTE_ADDR']);
		echo "<br> MySQL Error - " . mysql_errno() . ": " . mysql_error() . "<br>"; 
		$mailbody = "
		IP Addr: $_SERVER[REMOTE_ADDR]
		Browser: $_SERVER[HTTP_USER_AGENT]
		
		Page: $_SERVER[SCRIPT_FILENAME]?$_SERVER[QUERY_STRING]
		Date: " . date("D F j, Y, G:i:s") . "
		
		Host: $hostname
		Server: $_SERVER[HTTP_HOST]
		
		Referer: $_SERVER[HTTP_REFERER]


		MySQL Error - " . mysql_errno() . ": " . mysql_error() ."
		
		\n\n
		----------------------------------------
		Query: $query
		----------------------------------------";
		$headers = "From: datamenu1@milonic.com";
		$subject = "Milonic Data Menu Error";
		if($sendErrorReports)mail($adminEmail, $subject, $mailbody, $headers);
	}
	else
	{
		if (!ereg("^update", $query)) return mysql_fetch_array($qry);
	}
}


function buildMySQLMenu($menuProjectID)
{
	global $table_prefix, $menuVars;
	
	
	// Properties
	
	$query="select * from ".$table_prefix."projects where projectid = $menuProjectID";
	$ar=doquery($query);
	

	
	if(!$ar)die("Could not find menu project");
	
	$menuVars['menuCloseDelay']=$ar['menuCloseDelay'];
	$menuVars['menuOpenDelay']=$ar['menuOpenDelay'];
	$menuVars['subOffsetTop']=$ar['subOffsetTop'];
	$menuVars['subOffsetLeft']=$ar['subOffsetLeft'];

	
	$query="select distinct(styleid) from ".$table_prefix."menus where projectid = $menuProjectID";
	$sqry=runquery($query);
	
	$styles=array();
	
	while ($sar = mysql_fetch_array($sqry))
	{	
		$query="select * from ".$table_prefix."styles where styleid=$sar[styleid]";
		$ar=doquery($query);
		
		$mmStyle=new mmenuStyle();
		$sysCtr=0;
		foreach ($ar as $k => $v) 
		{
			if($sysCtr==1)$sysCtr=0; else $sysCtr=1;
			if($sysCtr==0)
			{
				if($k!="styleid" && $k!="name")
				$mmStyle->$k=$v;
			}
		}
	
		$mmStyle->createMenuStyle($ar['name']);
		$styles[$sar['styleid']]=$ar['name'];
	}	
	
	
	
	
	
	
	$query="select * from ".$table_prefix."menus where projectid = $menuProjectID";
	$mqry=runquery($query);
	
	while ($mar = mysql_fetch_array($mqry))
	{
		$sysCtr=0;
		$mmMenu=new mMenu();	
		foreach ($mar as $k => $v) 
		{
			if($sysCtr==1)$sysCtr=0; else $sysCtr=1;
			if($sysCtr==0)
			{
				if(($k!="menuid" && $k!="projectid" && $k!="name") && $v)
				{
					if($k=="styleid")
					{
						$k="style";
						$v=$styles[1];
					}
		
					$mmMenu->$k=$v;
				}
			}
		}	
	
		
		$sysCtr=0;
		$query="select * from ".$table_prefix."items where menuid=$mar[menuid]";
		$iqry=runquery($query);
		while ($iar = mysql_fetch_array($iqry))
		{
			$mmItem = new mItem();
			$andy=0;
			foreach ($iar as $k => $v) 
			{
				if($sysCtr==1)$sysCtr=0; else $sysCtr=1;
	
				if($sysCtr==0)
				{
					if(($k!="menuid" && $k!="itemid") && $v)
					{
						$mmItem->addItemElement($k, $v);
						
					}
	
				}
				
				
			}	
			$mmMenu->addItemFromItem($mmItem);
		}
	
		
				
	$mmMenu->createMenu($mar['name']);
	}

	commitMenus();
}




$menuData="";

class mmenuStyle
{
	
	function createMenuStyle($styleName)
	{
		global $menuData;
		$styleArray=get_object_vars($this);
		$menuData.="with($styleName=new mm_style()){\n";
		
		foreach ($styleArray as $k => $v) 
		{
			if(ereg("color",$k))
			{
				if(substr($v,0,1)!="#")$v="#".$v;
			}
			
			$menuData.= "$k=\"$v\";\n";
		}
   
		$menuData.= "}\n\n";
	}
}






class mMenu
{
	var $menuItems;
	function createMenu($menuName)
	{
		global $menuData;
		$menuArray=get_object_vars($this);

		$menuData.= "with(milonic=new menuname(\"$menuName\")){\n";
		$tempMenuItems="";
		foreach ($menuArray as $k => $v) 
		{
			global $menuData;
			if($k!="menuItems")
			{
				if($k=="style")
				{
					$menuData.= "$k=$v;\n";
				}
				else
				{
					$menuData.= "$k=\"$v\";\n";
				}
				
			}
			else
			{
				if($k=="menuItems")$tempMenuItems=$v;
			}
		}
   
   		$menuData.= $tempMenuItems."\n";
		$menuData.= "}\n\n";
	}
	
	
	function addItemFromText($itemText)
	{
		global $menuData;
		$this->menuItems.="aI(\"".$itemText . "\");\n";	
	}
	

	function addItemFromItem($menuItem)
	{
		global $menuData;
		$tempVar="";
		foreach ($menuItem as $k => $v) 
		{
			if(ereg("color",$k))
			{
				if(substr($v,0,1)!="#")$v="#".$v;
			}			
			
			$tempVar.="$k=$v;";
		}
		$this->menuItems.="aI(\"".$tempVar . "\");\n";	
	}	
	
}


class mItem
{
	function addItemElement($mtype,$mval)
	{
		$this->$mtype=$mval;
	}
}


function commitMenus()
{
	global $menuData,$menuVars;
	
	
echo "



<SCRIPT language=\"JavaScript\" src=\"$menuVars[pathToCodeFiles]$menuVars[file_milonicsrc]\" type=\"text/javascript\"></SCRIPT>	
<script	language=\"JavaScript\">

if(ns4)_d.write(\"<scr\"+\"ipt language=JavaScript src=$menuVars[pathToCodeFiles]$menuVars[file_mmenuns4]><\/scr\"+\"ipt>\");		
  else _d.write(\"<scr\"+\"ipt language=JavaScript src=$menuVars[pathToCodeFiles]$menuVars[file_mmenudom]><\/scr\"+\"ipt>\"); 
</script>
";

flush();
	

echo "<script>\n
_menuCloseDelay=$menuVars[menuCloseDelay];
_menuOpenDelay=$menuVars[menuOpenDelay];
_subOffsetTop=$menuVars[subOffsetTop];
_subOffsetLeft=$menuVars[subOffsetLeft]


$menuData";
echo "drawMenus();\n";
echo "</script>\n";	
}





?>



I take it...

Code: Select all

$menuData=""; 

class mmenuStyle 
{ 
    
   function createMenuStyle($styleName) 
   { 
      global $menuData; 
      $styleArray=get_object_vars($this); 
      $menuData.="with($styleName=new mm_style()){\n"; 
       
      foreach ($styleArray as $k => $v) 
      { 
         if(ereg("color",$k)) 
         { 
            if(substr($v,0,1)!="#")$v="#".$v; 
         } 
          
         $menuData.= "$k=\"$v\";\n"; 
      } 
    
      $menuData.= "}\n\n"; 
   } 
}
Makes the style(s). Don't know if it just looks for 1 or more styles?
The "createMenuStyle" gave it kinda away :roll: .


I hope this helps.
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

If I remember, all you need to do is create the styles in the styles table then reference them from the menu table.

The createMenuStyle() function will be called for each menu that it finds in the data.

Hope this helps,
Andy
AangepasteAuto
Advanced
Advanced
Posts: 13
Joined: Wed Jun 15, 2005 1:06 pm
Contact:

Post by AangepasteAuto »

Andy wrote:If I remember, all you need to do is create the styles in the styles table then reference them from the menu table.
As far as I can see I did this. I made a dump of the mm_menus and mm_styles part of the DB.
I hope that helps.

Code: Select all

-- phpMyAdmin SQL Dump
-- version 2.6.0-pl3
-- http://www.phpmyadmin.net
-- 
-- Host: 
-- Generatie Tijd: 28 Jun 2005 om 10:31
-- Server versie: 4.1.8
-- PHP Versie: 5.0.4
-- 
-- Database: ` `
-- 

-- --------------------------------------------------------

-- 
-- Tabel structuur voor tabel `mm_menus`
-- 

CREATE TABLE `mm_menus` (
  `menuid` int(11) NOT NULL auto_increment,
  `projectid` int(11) NOT NULL default '0',
  `styleid` int(11) NOT NULL default '0',
  `name` varchar(40) NOT NULL default '',
  `alwaysvisible` tinyint(1) default NULL,
  `orientation` tinyint(1) default NULL,
  `overflow` varchar(20) default NULL,
  PRIMARY KEY  (`menuid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;

-- 
-- Gegevens worden uitgevoerd voor tabel `mm_menus`
-- 

INSERT INTO `mm_menus` VALUES (1, 1, 1, 'Main Menu', 1, 1, NULL);
INSERT INTO `mm_menus` VALUES (2, 1, 2, 'Kopen Verkopen', NULL, NULL, NULL);
INSERT INTO `mm_menus` VALUES (3, 1, 2, 'Informatie voor bedrijven', NULL, NULL, NULL);
INSERT INTO `mm_menus` VALUES (4, 1, 2, 'Algemene voorwaarden', NULL, NULL, NULL);
INSERT INTO `mm_menus` VALUES (5, 1, 2, 'Links', NULL, NULL, NULL);
INSERT INTO `mm_menus` VALUES (6, 1, 2, 'Contact', NULL, NULL, NULL);

-- --------------------------------------------------------

-- 
-- Tabel structuur voor tabel `mm_styles`
-- 

CREATE TABLE `mm_styles` (
  `styleid` int(11) NOT NULL auto_increment,
  `image` varchar(255) default NULL,
  `overimage` varchar(255) default NULL,
  `imagealign` varchar(6) default NULL,
  `name` varchar(40) NOT NULL default '',
  `overfilter` varchar(100) default NULL,
  `outfilter` varchar(100) default NULL,
  `oncolor` varchar(6) default NULL,
  `onbgcolor` varchar(6) default NULL,
  `offcolor` varchar(6) default NULL,
  `offbgcolor` varchar(6) default NULL,
  `padding` tinyint(4) default NULL,
  `separatorcolor` varchar(6) NOT NULL default '',
  `separatorsize` tinyint(4) default NULL,
  `separatorpadding` tinyint(4) default NULL,
  `borderwidth` tinyint(4) default NULL,
  `fontfamily` varchar(50) default NULL,
  `fontsize` varchar(8) default NULL,
  `fontweight` varchar(6) NOT NULL default '',
  `ondecoration` varchar(12) NOT NULL default '',
  `pagecolor` varchar(6) default NULL,
  `pageimage` varchar(255) default NULL,
  PRIMARY KEY  (`styleid`),
  FULLTEXT KEY `fontweight` (`fontweight`),
  FULLTEXT KEY `separatorcolor` (`separatorcolor`),
  FULLTEXT KEY `ondecoration` (`ondecoration`),
  FULLTEXT KEY `overfilter` (`overfilter`),
  FULLTEXT KEY `outfilter` (`outfilter`),
  FULLTEXT KEY `subimageposition` (`imagealign`),
  FULLTEXT KEY `onsubimage` (`overimage`),
  FULLTEXT KEY `pagecolor` (`pagecolor`),
  FULLTEXT KEY `pageimage` (`pageimage`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=36 ;

-- 
-- Gegevens worden uitgevoerd voor tabel `mm_styles`
-- 

INSERT INTO `mm_styles` VALUES (1, './block_off.gif', './block_on.gif', 'left', 'miniStyle', NULL, NULL, '000000', 'FFFFFF', '999999', 'FFFFFF', 1, '000000', 1, 5, NULL, 'Verdana, Arial, Helvetica, sans-serif', 'x-small', 'bold', 'underline', '000000', './block_on.gif');
INSERT INTO `mm_styles` VALUES (2, './block_off.gif', './block_on.gif', 'left', 'link', 'Fade(duration=0.3);Shadow(color=''#BBBBBB'',Direction=135,Strength=3)', 'Fade(duration=0.3);Shadow(color=''#BBBBBB'',Direction=135,Strength=3)', '000000', 'FFFFFF', '999999', 'FFFFFF', 1, '000000', 1, 0, 1, 'Verdana, Arial, Helvetica, sans-serif', 'xx-small', 'bold', 'underline', '000000', './block_on.gif');
As you can see I added a extra stylesheet with number 2 and a different name.
In mm_menus I gave the main menu styleid 1 and the other (drop down) menus styleid 2.
slackbladder
Super Advanced
Super Advanced
Posts: 72
Joined: Fri Jul 01, 2005 3:04 pm

Post by slackbladder »

Bump

I am also having the same problem with the MySQL / PHP solution. I can't create more than one style.


Thx
slackbladder
Super Advanced
Super Advanced
Posts: 72
Joined: Fri Jul 01, 2005 3:04 pm

Post by slackbladder »

OK! I have been playing and this seems to fix the issue - however was sorted by more luck than judgement, so anyone with more knowledge please jump in.


In mm_phpmenu.php

Look for:

Code: Select all

if($k=="styleid")
{
$k="style";
$v=$styles[1];
}
Change to:

Code: Select all

if($k=="styleid")
{
$k="style";
$v=$styles[$mar[styleid]];
}
Worked for me - but haven't fully tested it yet. Will post back if I realise I have made a fool of myself and posted a 'duff' fix :lol:
slackbladder
Super Advanced
Super Advanced
Posts: 72
Joined: Fri Jul 01, 2005 3:04 pm

Post by slackbladder »

Ah! Just found another issue. If you are not using a colour in the following references in mm_items in your MySQL db:

oncolor
onbgcolor
offcolor
offbgcolor

then IE6 (PC) causes java script error (OK in MAC firefox). This is caused by mm_phpmenu.php inserting a '#' automatically but not checking if there is actually something in the field first.

My 'workaround' is:

In mm_phpmenu.php find:

Code: Select all

foreach ($styleArray as $k => $v) 
		{
			if(ereg("color",$k))
			{
			
				if(substr($v,0,1)!="#")$v="#".$v;
			}
			$menuData.= "$k=\"$v\";\n";
		}
Change to:

Code: Select all

foreach ($styleArray as $k => $v) 
		{
		if($v != ''){
			if(ereg("color",$k))
			{
			
				if(substr($v,0,1)!="#")$v="#".$v;
			}
			}
			$menuData.= "$k=\"$v\";\n";
		}
Again I am not that clued up on PHP or MySQL but the fix work for me :D
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

Well spotted! :D

I've now updated the files, almost the same code as yours but with slight differences.

Cheers,
Andy
slackbladder
Super Advanced
Super Advanced
Posts: 72
Joined: Fri Jul 01, 2005 3:04 pm

Post by slackbladder »

Wow! Nice to know I wasn't too far off :D

Where is the updated code?

http://support.milonic.com/datamenu/ ?
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

Hi,

I'm not sure if they are up there yet, though probably since Andy is really good on that, but they should be in the new version, which Andy hopes to get out today sometime [5.728] There is a pre-release of that version under the menu version info section, but again, I don't know if the new stuff is in it yet.

I don't know much today ;)

Ruth
AangepasteAuto
Advanced
Advanced
Posts: 13
Joined: Wed Jun 15, 2005 1:06 pm
Contact:

Post by AangepasteAuto »

WOOHOO thank you very much for fixing it slackbladder.
Finally it will work... and Milonic will become a little richer when I buy a license now ;-).
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

Should now be posted up to the main download and to http://support.milonic.com/datamenu/

Cheers,
Andy
AangepasteAuto
Advanced
Advanced
Posts: 13
Joined: Wed Jun 15, 2005 1:06 pm
Contact:

Post by AangepasteAuto »

Is it just me. Or does the overfilter and outfilter work nomore now?
slackbladder
Super Advanced
Super Advanced
Posts: 72
Joined: Fri Jul 01, 2005 3:04 pm

Post by slackbladder »

Where are you using it? It's not working in the link you posted above - but that may be because you are not using the style ('link') in any of the menus? It has been added to your styles list, but not used.
AangepasteAuto
Advanced
Advanced
Posts: 13
Joined: Wed Jun 15, 2005 1:06 pm
Contact:

Post by AangepasteAuto »

Oops, not smart to have more then 1 "test places" :-). Had it on my local computer.

I've uploaded the mm_phpmenu.php file Andy put on the server on my test site now. The link should show it all now.
Post Reply