Hi all i am new to cake php please help me
My problem is:
common code for all the controller methods and other controller
methods also
----------------------common code start-----------------------
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"
);
------------------------common code end------------------------
Ex: user controller
function index($intCurrentMenu=-1){
####### here i have to use common code ########
$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='index';
$ctrl='users';
$this->set('method', $method );
$this->set('ctrl', $ctrl );
}
function otherindex($intCurrentMenu=-1){
####### here i have to use common code ########
$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='otherindex';
$ctrl='users';
$this->set('method', $method );
$this->set('ctrl', $ctrl );
}
My view file like this : 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>
</tr>
</table>
includer file code here :views/elements/gravitybar.ctp
------------------------------------------------------------------------------
<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'=>'index',$intCurrentMenu,)));
?>
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0"
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>
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