...

View Full Version : Beginner question



taelmx
08-02-2007, 04:09 PM
I'm pretty new to php, and I was trying to modify a TransMenu script to work in with my subdreamer cms. I had to edit the categories.php file only. When I go to my site, it says:


Parse error: parse error, unexpected $ on line 184

I'm pretty sure all my braces are closed, but I still get the error.

Here's the code for it. I commented out the subcatagory code for now just to test the catagory rows first:


<?php

echo '
<link rel="stylesheet" href="/skins/euro/transmenu.css" type="text/css" />


<script language="javascript" src="/skins/euro/transmenuC.js"></script>
<script language="javascript">

function init() {
//==========================================================================================
// if supported, initialize TransMenus
//==========================================================================================
// Check isSupported() so that menus arent accidentally sent to non-supporting browsers.
// This is better than server-side checking because it will also catch browsers which would
// normally support the menus but have javascript disabled.
//
// If supported, call initialize() and then hook whatever image rollover code you need to do
// to the .onactivate and .ondeactivate events for each menu.
//==========================================================================================
if (TransMenu.isSupported()) {
TransMenu.initialize();

// hook all the highlight swapping of the main toolbar to menu activation/deactivation
// instead of simple rollover to get the effect where the button stays hightlit until
// the menu is closed.

';
for($i = 0; $i < $categoryrows; $i++)
{
echo 'menu'.$i.'.onactivate = function() { document.getElementById("'.$categoryname[$i].'").className = "hover"; };
menu'.$i.'.ondeactivate = function() { document.getElementById("'.$categoryname[$i].'").className = ""; };
}
}';

echo '
}
</script>
</head>
<body onload="init()">


<table cellpadding="0" cellspacing="0" border="0">
<tr>';

for($i = 0; $i < $categoryrows; $i++)
{
echo '

<td width="10" height="28"><img src="skins/euro/images/cat_center.jpg" /></td>
<td width="100" height="28" align="center" background="skins/euro/images/cat_center.jpg">
<a id="'.$categoryname[$i].'" href="" class="category">'.$categoryname[$i].'</a>
</td><td width="10" height="28"><img src="skins/euro/images/cat_right.jpg" /></td>';

};

echo '


</tr>
</table>

<script language="javascript">

// set up drop downs anywhere in the body of the page. I think the bottom of the page is better..
// but you can experiment with effect on loadtime.
if (TransMenu.isSupported()) {

//==================================================================================================
// create a set of dropdowns
//==================================================================================================
// the first param should always be down, as it is here
//
// The second and third param are the top and left offset positions of the menus from their actuators
// respectively. To make a menu appear a little to the left and bottom of an actuator, you could use
// something like -5, 5
//
// The last parameter can be .topLeft, .bottomLeft, .topRight, or .bottomRight to inidicate the corner
// of the actuator from which to measure the offset positions above. Here we are saying we want the
// menu to appear directly below the bottom left corner of the actuator
//==================================================================================================
var ms = new TransMenuSet(TransMenu.direction.down, 0, 0, TransMenu.reference.bottomLeft);

//==================================================================================================
// create a dropdown menu
//==================================================================================================
// the first parameter should be the HTML element which will act actuator for the menu
//==================================================================================================


//==================================================================================================

//==================================================================================================

';

for($i = 0; $i < $categoryrows; $i++)
{
echo '
var menu'.$i.' = ms.addMenu(document.getElementById("'.$categoryname[$i].'"));
menu1.addItem("Download Anime", "http://www.manga4otaku.com/forums/index.php?autocom=articles&code=showcat&id=1");
menu1.addItem("Download Anime OST", "http://www.manga4otaku.com/forums/index.php?autocom=articles&code=showcat&id=2");
menu1.addItem("Download Artbooks", "http://www.manga4otaku.com/forums/index.php?autocom=articles&code=showcat&id=3");
menu1.addItem("Download Movies", "http://www.manga4otaku.com/forums/index.php?autocom=articles&code=showcat&id=4");
menu1.addItem("Download Music", "http://www.manga4otaku.com/forums/index.php?autocom=articles&code=showcat&id=5");
menu1.addItem("Get Megaupload Premium Links", "http://www.manga4otaku.com/forums/index.php?act=ST&f=149&t=4783");
';
};
/*
var submenu3 = menu3.addMenu(menu3.items[2]);
submenu3.addItem("My Character", "http://www.manga4otaku.com/forums/living_avatars/index.php");
submenu3.addItem("My Families", "http://www.manga4otaku.com/forums/index.php?autocom=families");
submenu3.addItem("My Blog", "http://www.manga4otaku.com/forums/index.php?autocom=blogs");

var submenu3 = menu3.addMenu(menu3.items[3]);
submenu3.addItem("Flash Galleries", "http://www.manga4otaku.com/forums/index.php?act=m4ogalleries");
submenu3.addItem("Flash Media", "http://www.manga4otaku.com/forums/index.php?act=m4omedia");
submenu3.addItem("Flash Upload", "http://www.manga4otaku.com/forums/index.php?act=SR&f=225");

var submenu3 = menu3.addMenu(menu3.items[4]);
submenu3.addItem("Manga Projects", "http://www.manga4otaku.com/forums/index.php?act=m4oprojects");
submenu3.addItem("Website Tutorials", "http://www.manga4otaku.com/forums/index.php?act=m4otutorials");
submenu3.addItem("Banned Members", "http://www.manga4otaku.com/forums/index.php?act=ban");
submenu3.addItem("Image Host", "http://www.manga4otaku.com/forums/index.php?act=imageupload");

var menu4 = ms.addMenu(document.getElementById("navRPG"));
menu4.addItem("RPG Modules", "");
menu4.addItem("M4O Banking", "");
menu4.addItem("M4O Shopping", "");
menu4.addItem("Other Games", "");
menu4.addItem("Casino System", "http://www.manga4otaku.com/forums/index.php?autocom=casino");
menu4.addItem("Arcade System", "http://www.manga4otaku.com/forums/index.php?autocom=arcade");
menu4.addItem("Refer Friends", "http://www.manga4otaku.com/forums/index.php?autocom=arcade");

var submenu4 = menu4.addMenu(menu4.items[0]);
submenu4.addItem("RPG Pokemons", "http://www.manga4otaku.com/forums/index.php?act=pokemons");
submenu4.addItem("RPG Battle", "http://www.manga4otaku.com/forums/index.php?act=atkshop");
submenu4.addItem("RPG Guilds", "http://www.manga4otaku.com/forums/index.php?act=guilds");
submenu4.addItem("RPG Army", "http://www.manga4otaku.com/forums/index.php?autocom=army&core=armysystem2");
submenu4.addItem("RPG Inferno", "http://www.manga4otaku.com/forums/inferno.php?do=worldmap")
var submenu4 = menu4.addMenu(menu4.items[3]);
submenu4.addItem("M4O Lottery","http://www.manga4otaku.com/forums/index.php?act=p_lottery");
submenu4.addItem("M4O Quizzes","http://www.manga4otaku.com/forums/index.php?act=p_quiz");
submenu4.addItem("M4O Raffle","http://www.manga4otaku.com/forums/index.php?act=raffle");
submenu4.addItem("M4O Trivia","http://www.manga4otaku.com/forums/index.php?autocom=challenge");
submenu4.addItem("M4O Sudoku","http://www.manga4otaku.com/forums/index.php?autocom=sudoku");

var submenu4 = menu4.addMenu(menu4.items[2]);
submenu4.addItem("Manga Items","http://www.manga4otaku.com/forums/index.php?act=shop&cat=40");
submenu4.addItem("Pets Items","http://www.manga4otaku.com/forums/index.php?act=shop&cat=160");


var submenu4 = menu4.addMenu(menu4.items[1]);
submenu4.addItem("M4O Bank","http://www.manga4otaku.com/forums/index.php?act=bank");
submenu4.addItem("Army Bank","http://www.manga4otaku.com/forums/index.php?autocom=army&core=bank");
submenu4.addItem("Poki Bank","http://www.manga4otaku.com/forums/index.php?act=pokemons&CODE=store");
submenu4.addItem("Quick Bank","http://www.manga4otaku.com/forums/index.php?autocom=banksm");

var submenu4 = menu4.addMenu(menu4.items[6]);
submenu4.addItem("Send Referrals","http://www.manga4otaku.com/forums/index.php?autocom=referal&code=choices");
submenu4.addItem("Pending Referrals","http://www.manga4otaku.com/forums/index.php?autocom=referal&code=pending");
submenu4.addItem("Finished Referrals","http://www.manga4otaku.com/forums/index.php?autocom=referal&code=downline");
submenu4.addItem("Cash Awards","http://www.manga4otaku.com/forums/index.php?autocom=referal&code=structure");
submenu4.addItem("Top Referrals","http://www.manga4otaku.com/forums/index.php?autocom=referal&code=leaderboard");


*/


echo '

//==================================================================================================

//==================================================================================================
// write drop downs into page
//==================================================================================================
// this method writes all the HTML for the menus into the page with document.write(). It must be
// called within the body of the HTML page.
//==================================================================================================
TransMenu.renderAll();
}

</script>';
?>

Thanks for helping me out with this! =D

_Aerospace_Eng_
08-02-2007, 04:20 PM
Do you see your error?

for($i = 0; $i < $categoryrows; $i++)
{
echo 'menu'.$i.'.onactivate = function() { document.getElementById("'.$categoryname[$i].'").className = "hover"; };
menu'.$i.'.ondeactivate = function() { document.getElementById("'.$categoryname[$i].'").className = ""; };
}
}';

taelmx
08-02-2007, 10:28 PM
Ok thanks I fixed it...

I'm still having problems with getting them to display though...

here's the modified version:


<?php

echo '
<link rel="stylesheet" href="/skins/euro/transmenu.css" type="text/css" />


<script language="javascript" src="/skins/euro/transmenuC.js"></script>
<script language="javascript">

function init() {
//==========================================================================================
// if supported, initialize TransMenus
//==========================================================================================
// Check isSupported() so that menus arent accidentally sent to non-supporting browsers.
// This is better than server-side checking because it will also catch browsers which would
// normally support the menus but have javascript disabled.
//
// If supported, call initialize() and then hook whatever image rollover code you need to do
// to the .onactivate and .ondeactivate events for each menu.
//==========================================================================================
if (TransMenu.isSupported()) {
TransMenu.initialize();

// hook all the highlight swapping of the main toolbar to menu activation/deactivation
// instead of simple rollover to get the effect where the button stays hightlit until
// the menu is closed.

';
for($i = 0; $i < $categoryrows; $i++)
{
echo 'menu'.$i.'.onactivate = function() { document.getElementById("'.$categoryname[$i].'").className = "hover"; };
menu'.$i.'.ondeactivate = function() { document.getElementById("'.$categoryname[$i].'").className = ""; };';

};

echo '
}
</script>
</head>
<body onload="init()">


<table cellpadding="0" cellspacing="0" border="0">
<tr>';

for($i = 0; $i < $categoryrows; $i++)
{
echo '

<td width="10" height="28"><img src="skins/euro/images/cat_center.jpg" /></td>
<td width="100" height="28" align="center" background="skins/euro/images/cat_center.jpg">
<a id="'.$categoryname[$i].'" href="" class="category">'.$categoryname[$i].'</a>
</td><td width="10" height="28"><img src="skins/euro/images/cat_right.jpg" /></td>';

};

echo '


</tr>
</table>

<script language="javascript">

// set up drop downs anywhere in the body of the page. I think the bottom of the page is better..
// but you can experiment with effect on loadtime.
if (TransMenu.isSupported()) {

//==================================================================================================
// create a set of dropdowns
//==================================================================================================
// the first param should always be down, as it is here
//
// The second and third param are the top and left offset positions of the menus from their actuators
// respectively. To make a menu appear a little to the left and bottom of an actuator, you could use
// something like -5, 5
//
// The last parameter can be .topLeft, .bottomLeft, .topRight, or .bottomRight to inidicate the corner
// of the actuator from which to measure the offset positions above. Here we are saying we want the
// menu to appear directly below the bottom left corner of the actuator
//==================================================================================================
var ms = new TransMenuSet(TransMenu.direction.down, 0, 0, TransMenu.reference.bottomLeft);

//==================================================================================================
// create a dropdown menu
//==================================================================================================
// the first parameter should be the HTML element which will act actuator for the menu
//==================================================================================================


//==================================================================================================

//==================================================================================================

';

for($i = 0; $i < $categoryrows; $i++)
{
echo '
var menu'.$i.' = ms.addMenu(document.getElementById("'.$categoryname[$i].'"));
menu'.$i.'.addItem("Download Anime", "http://www.manga4otaku.com/forums/index.php?autocom=articles&code=showcat&id=1");
menu'.$i.'.addItem("Download Anime OST", "http://www.manga4otaku.com/forums/index.php?autocom=articles&code=showcat&id=2");
menu'.$i.'.addItem("Download Artbooks", "http://www.manga4otaku.com/forums/index.php?autocom=articles&code=showcat&id=3");
menu'.$i.'.addItem("Download Movies", "http://www.manga4otaku.com/forums/index.php?autocom=articles&code=showcat&id=4");
menu'.$i.'.addItem("Download Music", "http://www.manga4otaku.com/forums/index.php?autocom=articles&code=showcat&id=5");
menu'.$i.'.addItem("Get Megaupload Premium Links", "http://www.manga4otaku.com/forums/index.php?act=ST&f=149&t=4783");
';
};
/*
var submenu3 = menu3.addMenu(menu3.items[2]);
submenu3.addItem("My Character", "http://www.manga4otaku.com/forums/living_avatars/index.php");
submenu3.addItem("My Families", "http://www.manga4otaku.com/forums/index.php?autocom=families");
submenu3.addItem("My Blog", "http://www.manga4otaku.com/forums/index.php?autocom=blogs");

var submenu3 = menu3.addMenu(menu3.items[3]);
submenu3.addItem("Flash Galleries", "http://www.manga4otaku.com/forums/index.php?act=m4ogalleries");
submenu3.addItem("Flash Media", "http://www.manga4otaku.com/forums/index.php?act=m4omedia");
submenu3.addItem("Flash Upload", "http://www.manga4otaku.com/forums/index.php?act=SR&f=225");

var submenu3 = menu3.addMenu(menu3.items[4]);
submenu3.addItem("Manga Projects", "http://www.manga4otaku.com/forums/index.php?act=m4oprojects");
submenu3.addItem("Website Tutorials", "http://www.manga4otaku.com/forums/index.php?act=m4otutorials");
submenu3.addItem("Banned Members", "http://www.manga4otaku.com/forums/index.php?act=ban");
submenu3.addItem("Image Host", "http://www.manga4otaku.com/forums/index.php?act=imageupload");

var menu4 = ms.addMenu(document.getElementById("navRPG"));
menu4.addItem("RPG Modules", "");
menu4.addItem("M4O Banking", "");
menu4.addItem("M4O Shopping", "");
menu4.addItem("Other Games", "");
menu4.addItem("Casino System", "http://www.manga4otaku.com/forums/index.php?autocom=casino");
menu4.addItem("Arcade System", "http://www.manga4otaku.com/forums/index.php?autocom=arcade");
menu4.addItem("Refer Friends", "http://www.manga4otaku.com/forums/index.php?autocom=arcade");

var submenu4 = menu4.addMenu(menu4.items[0]);
submenu4.addItem("RPG Pokemons", "http://www.manga4otaku.com/forums/index.php?act=pokemons");
submenu4.addItem("RPG Battle", "http://www.manga4otaku.com/forums/index.php?act=atkshop");
submenu4.addItem("RPG Guilds", "http://www.manga4otaku.com/forums/index.php?act=guilds");
submenu4.addItem("RPG Army", "http://www.manga4otaku.com/forums/index.php?autocom=army&core=armysystem2");
submenu4.addItem("RPG Inferno", "http://www.manga4otaku.com/forums/inferno.php?do=worldmap")
var submenu4 = menu4.addMenu(menu4.items[3]);
submenu4.addItem("M4O Lottery","http://www.manga4otaku.com/forums/index.php?act=p_lottery");
submenu4.addItem("M4O Quizzes","http://www.manga4otaku.com/forums/index.php?act=p_quiz");
submenu4.addItem("M4O Raffle","http://www.manga4otaku.com/forums/index.php?act=raffle");
submenu4.addItem("M4O Trivia","http://www.manga4otaku.com/forums/index.php?autocom=challenge");
submenu4.addItem("M4O Sudoku","http://www.manga4otaku.com/forums/index.php?autocom=sudoku");

var submenu4 = menu4.addMenu(menu4.items[2]);
submenu4.addItem("Manga Items","http://www.manga4otaku.com/forums/index.php?act=shop&cat=40");
submenu4.addItem("Pets Items","http://www.manga4otaku.com/forums/index.php?act=shop&cat=160");


var submenu4 = menu4.addMenu(menu4.items[1]);
submenu4.addItem("M4O Bank","http://www.manga4otaku.com/forums/index.php?act=bank");
submenu4.addItem("Army Bank","http://www.manga4otaku.com/forums/index.php?autocom=army&core=bank");
submenu4.addItem("Poki Bank","http://www.manga4otaku.com/forums/index.php?act=pokemons&CODE=store");
submenu4.addItem("Quick Bank","http://www.manga4otaku.com/forums/index.php?autocom=banksm");

var submenu4 = menu4.addMenu(menu4.items[6]);
submenu4.addItem("Send Referrals","http://www.manga4otaku.com/forums/index.php?autocom=referal&code=choices");
submenu4.addItem("Pending Referrals","http://www.manga4otaku.com/forums/index.php?autocom=referal&code=pending");
submenu4.addItem("Finished Referrals","http://www.manga4otaku.com/forums/index.php?autocom=referal&code=downline");
submenu4.addItem("Cash Awards","http://www.manga4otaku.com/forums/index.php?autocom=referal&code=structure");
submenu4.addItem("Top Referrals","http://www.manga4otaku.com/forums/index.php?autocom=referal&code=leaderboard");


*/


echo '

//==================================================================================================

//==================================================================================================
// write drop downs into page
//==================================================================================================
// this method writes all the HTML for the menus into the page with document.write(). It must be
// called within the body of the HTML page.
//==================================================================================================
TransMenu.renderAll();
}

</script>';
?>

I got all the rows to appear, but I can't get the subcatagories to drop down.

it might be because of the rows having the same subcatagory names, but I can't find the variable in subdreamer to get the subcatagory rows and names...I have to submit a ticket for that really quick...

Here is the code from the catagories.php file that has support for some CSS subcatagories:


<?php
// +---------------------------------------------+
// | Copyright 2003 2005 Subdreamer |
// | http://www.subdreamer.com |
// | This file may not be redistributed. |
// +---------------------------------------------+

if(!defined('IN_SUBDREAMER'))
{
die("Hacking attempt!");
}


if($usehovermenu = $DB->query_first("SELECT categoryid FROM " . TABLE_PREFIX . "categories WHERE parentid != 0 LIMIT 1"))
{
echo "
<script language=\"JavaScript\">
<!--
function wrap_root (text)
{
/*normal, hover, click*/
return ['<table><tr><td><table><tr><td>' + text + '</td></tr></table></td></tr></table>',
'<table><tr><td><table><tr><td>' + text + '</td></tr></table></td></tr></table>',
'<table><tr><td><table><tr><td>' + text + '</td></tr></table></td></tr></table>'
];
}

function wrap_parent (text, icon, hovericon)
{
/*normal, hover, click*/
return [['<table><tr><td><table><tr><td> ' + text + '</td></tr></table></td></tr></table>'].join(''),
['<table><tr><td><table><tr><td> ' + text + '</td></tr></table></td></tr></table>'].join(''),
['<table><tr><td><table><tr><td> ' + text + '</td></tr></table></td></tr></table>'].join('')
];
}

function wrap_child (text, icon, hovericon)
{
/*normal, hover, click*/
return [['<table><tr><td><table><tr><td> ' + text + '</td></tr></table></td></tr></table>'].join(''),
['<table><tr><td><table><tr><td> ' + text + '</td></tr></table></td></tr></table>'].join(''),
['<table><tr><td><table><tr><td> ' + text + '</td></tr></table></td></tr></table>'].join('')
];
}


var MENU_POS =[
// Level 0 block configuration
{
// Item's height in pixels
'height' : 28,

// Item's width in pixels
'width' : 100,

// if Block Orientation is vertical
'vertical' : false,

// Time Delay in milliseconds before subling block expands
// after mouse pointer overs an item
'expd_delay' : 0,

// Style class names for the level
'css':
{
// Block outing table class
'table' : '',

// Item outer tag style class for all item states or
// classes for [<default state>, <hovered state>, <clicked state>]
'outer' : '',

// Item inner tag style class for all item states or
// classes for [<default state>, <hovered state>, <clicked state>]
'inner' : ''
}
},
// Level 1 block configuration
{
'width' : 100,
'height' : 28,

// Vertical Offset between adjacent levels in pixels
'block_top' : 28,

// Horizontal Offset between adjacent levels in pixels
'block_left' : 0,

// block behaviour if single frame:
// 1 - shift to the edge, 2 - flip relatively to left upper corner
'wise_pos' : 1,
'vertical' : true,

// transition effects for the block
// [index on expand, duration on expand, index on collapse, duration on collapse]
'transition' : [0, 0.3, 0, 0.3],

// Time Delay in milliseconds before menu collapses after mouse
// pointer lefts all items
'hide_delay' : 300,
'css' :
{
'table' : '',
'outer' : '',
'inner' : ''
}
},
// Level 2 block configuration
{
'block_top' : 0,
'block_left' : 100
}
//Subling level configurations are inherited from level 2
]

var MENU_ITEMS = [";

CreateHoverMenu();

echo "];

new menu (MENU_ITEMS, MENU_POS);

//-->
</script>";
}
else
{
echo '<table border="0" cellpadding="0" cellspacing="0"><tr>';

// use normal category menu
for($i = 0; $i < $categoryrows; $i++)
{
echo '<td"><div><a href="'.$categorylink[$i].'" class="category">'.$categoryname[$i].'</a></div></td>';
}

echo '</tr></table>';

}



?>

_Aerospace_Eng_
08-02-2007, 10:30 PM
You commented out the submenus so how do you expect them to work?

taelmx
08-03-2007, 12:10 AM
Well, I didn't comment out the first five lines of defined submenus, but I think it's not working because you can't have multiple submenu names or something.

I'm gonna give up on integrating the menus with subdreamer for now since I need something to show right now. I got the menus to work without the php, so I think I'll set it up manually first and then maybe work on this later for my own menu.

I hate doing something manually, but it looks like that will be a lot faster than trying to integrate it.

I'll pick this up later though =)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum