Hi All,
I am new to cakephp, When i am try to create menu i have problem,
where can i write controller for elements please help me out.
include file code here : views/elements/gravitybar.ctp
------------------------------------------------------------------------------
---------------gravitybar.ctp code start-----------
<CENTER>
<?php
$intCurrentMenuDispplay=$intCurrentMenu;
?>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" align=center>
<TR>
<TD> </TD>
</TR>
<?php
//---POPU LATE THE PARENT MENU---
$arrImages[0] = "wizard.png";
$arrImages[1] = "announcements.png";
$arrImages[2] = "music.png";
$arrImages[3] = "settings.png";
$arrImages[4] = "logs.png";
$arrImages[5] = "program_options.png";
for($mainmenu = 0;$mainmenu < count($arrMenuItem);$mainmenu++){
$strMainMenu = $arrMenuItem[$mainmenu];
$hint = $arrMenuHint[$mainmenu];
$strMainMenu2 = "$mainmenu";
if("$mainmenu" == "$intCurrentMenu"){
$strMainMenu2 = "";
}
?>
<TR>
<TD ALIGN="center">
<?php
$intCurrentMenu=$strMainMenu2;
echo $html-
>image($arrImages[$mainmenu],array('title'=>$hint,
'border'=>0,
'url' => array(
'controller'=>$ctrl,
'action'=>'$metchod',
$intCurrentMenu,)));
?>
<TABLE align=center BGCOLOR="#4E4E4E">
<?php
//---POPULATE THE CHILD MENU---
if($intCurrentMenuDispplay == $mainmenu) {
for($submenu = 0;
$submenu < count($arrMenuChild[$mainmenu]);
$submenu++){
$strSubMenu = $arrMenuChild[$mainmenu]
[$submenu];
$strMenuImg = $arrMenuImg[$mainmenu]
[$submenu];
$strMenuURL = $arrMenuURL[$mainmenu]
[$submenu];
$strHeader =
stripslashes(urlencode("$strSubMenu"));
?>
<TR>
<TD ALIGN="center" NOWRAP>
<BR />
<?php echo $html-
>image($strMenuImg,array('title'=> $hint,
'border'=>0,
'url' =>
array(
'controller'=>$ctrl,
'action'=>'index',$strMenuURL,)));
?>
<BR />
<FONT SIZE="1" COLOR="#FFFFFF" >
<B>
<?php
echo stripslashes("$strSubMenu");
?>
</B>
</FONT>
</A>
<?php
if(($submenu + 1) ==
count($arrMenuChild[$mainmenu])) {
?>
<BR><BR>
<?php
}
?>
</TD>
</TR>
<?php
}
}
?>
</TABLE></TD>
</TR>
<?php
}
?>
</TABLE>
</CENTER>
---------------gravitybar.ctp code end-----------
Controller method
-----------------------
function gravitybar($intCurrentMenu=-1){
if(!isset($intCurrentMenu)){
$intCurrentMenu = "-1";
// $this->set('intCurrentMenu', $intCurrentMenu );
}
if($intCurrentMenu == ""){
$intCurrentMenu = "-1";
$this->set('intCurrentMenu', $intCurrentMenu );
}
if(isset($intCurrentMenu)){
// $this->set('intCurrentMenu', $intCurrentMenu );
}
###### Start menu population ######
$arrMenuItem = array("Wizard",
"Advertisements",
"Music",
"Settings",
"Logs",
"Program Options"
);
$arrMenuHint = array("Links on wizard main page",
"Play advertisements",
"Manipulate music",
"Change settings",
"View logs",
"Create users and groups");
//$strURLDir = "player/";
$arrMenuChild[0] = array("Volumes",
"Format Clock",
"Times",
"Today's Music",
"Feedback",
"Profiles",
"Media Loader",
"System",
"Reports",
"Details",
"Broadcast Manager"
);
$arrMenuImg[0] = array("wizard_volume.png",
"format_clock.gif",
"wizard_time.png",
"wizard_music.png",
"wizard_feedback.png",
"wizard_profile.png",
"media_loader1.png",
"wizard_diagnostic.png",
"wizard_reports.png",
"wizard_details.png",
"broadcast1.png"
);
$arrMenuURL[0] = array("volumes.php",
"format_clock/index.php",
"store_times.php",
"todays_music.php",
"feedback.php",
"profiles.php",
"medialoader.php",
"system.php",
"menu.php",
"store_details.php",
"broadcastmanagement.php"
);
//$strURLDir = "";
$arrMenuChild[1] = array("Play an Advertisement",
"Multiple Scheduler",
"Media Loader",
"Advertisement Schedule",
"Scheduled Files In Waiting",
"Scheduled Files Played"
);
$arrMenuImg[1] = array("play.gif",
"multiple.png",
"medialoader.png",
"annsched.png",
"schedfileswait.png",
"schedfilesplayed.png"
);
$arrMenuURL[1] = array("custom_scheduler.php",
"custom_scheduler_multiple.php",
"medialoader.php",
"announcement_schedule.php",
"schedfiles_waiting.php",
"schedfiles_played.php"
);
//$strURLDir = "";
$arrMenuChild[2] = array("Music History",
"Music Profiles",
"Media Loader",
"CD-ROM Tray"
);
$arrMenuImg[2] = array("music_history.gif",
"music_profiles.png",
"medialoader.png",
"cdromtray.png"
);
$arrMenuURL[2] = array("music_history.php",
"music_profiles.php",
"medialoader.php",
"cdromtray.php"
);
//$strURLDir = "";
$arrMenuChild[3] = array("Settings",
"Volume Settings",
"System",
"Details"
);
$arrMenuImg[3] = array("wizard_time.png",
"wizard_volume.png",
"system1.png",
"storedetails.png"
);
$arrMenuURL[3] = array("store_settings.php",
"volume_settings.php",
"system.php",
"store_details.php"
);
//$strURLDir = "";
$arrMenuChild[4] = array("Item Log",
"Player Log",
"Loader Log"
);
$arrMenuImg[4] = array("log_2.png",
"program_log.png",
"log_1.png"
);
$arrMenuURL[4] = array("logs.php?intAction=1",
"logs.php?intAction=3",
"logs.php?intAction=2"
);
//$strURLDir = "";
$arrMenuChild[5] = array("Users",
"Groups",
"Database",
"Paths",
"Defaults",
"Security"
);
$arrMenuImg[5] = array("users.png",
"groups.png",
"database.gif",
"paths.png",
"defaults.png",
"security.png"
);
$arrMenuURL[5] = array("users_groups.php?intAction=100",
"users_groups.php?intAction=101",
"database.php",
"paths.php",
"defaults.php",
"security.php"
);
$this->set('arrMenuItem', $arrMenuItem);
$this->set('arrMenuHint', $arrMenuHint );
$this->set('arrMenuChild', $arrMenuChild );
$this->set('arrMenuURL', $arrMenuURL );
$this->set('arrMenuImg', $arrMenuImg );
$this->set('intCurrentMenu', $intCurrentMenu );
$method='';
$ctrl='';
$this->set('method', $method );
$this->set('ctrl', $ctrl );
}
---------------------------------------------
View files
---------------
Ex:1 index.ctp
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<!-- Navigation Menu Start-->
<td width="224" align="left" valign="top" bgcolor="#4E4E4E">
<?php
echo $this->element('gravitybar')
?>
</td>
</table>
Ex:2 security.ctp
-----------------
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<!-- Navigation Menu Start-->
<td width="224" align="left" valign="top" bgcolor="#4E4E4E">
<?php
echo $this->element('gravitybar')
?>
</td>
</table>
Ex:3 logs.ctp
-----------------
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<!-- Navigation Menu Start-->
<td width="224" align="left" valign="top" bgcolor="#4E4E4E">
<?php
echo $this->element('gravitybar')
?>
</td>
</table>
These are all different view files have different controllers, i have
to use same menu for all these files,
and in which controller i have to write gravitybar method,please help
me out...
thanks in advance
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en