// create a folder named modules in your app directory & create module
code like this:
// suppose you want to create module for company search
app/modules/mod_company_search.php
<?
/*function mod_companySearch($components='',$model='')
{ */
// echo $objModel;
$Categoryresults = $this->getRows('Category');
$Countryresults = $this->getRows('Country');
$Stateresults = $this->getRows('State');
$str="
<div id='company_search'> Company Search</div>
<div id='search_bg'>
<div class='spacer'></div>
<div >Category:
<select name='category' size='1' class='options_txt' style='width:
165px;'>
<option value='0'>Select Category</option>";
foreach($Categoryresults as $rows)
{
$str.="<option value='$rows[id]'>$rows[name]</option>";
}
$str.="</select>
</div>
<div>State:<img src=".IMAGES."white_spacer.gif' alt='' width='1'
height='1' border='0'/>
<select name='state' class='options_txt' style='width:165px;'>
<option value='0'>Search US State</option>";
foreach($Stateresults as $rows)
{
$str.="<option value='$rows[state_id]'>$rows[state_name]</
option>";
}
$str.="</select>
</div>
<div>Country:
<select name='country' class='options_txt' style='width:165px;'>
<option value='0'>Search Country</option>";
foreach($Countryresults as $rows)
{
$str.="<option value='$rows[country_id]'>$rows[country_name]</
option>";
}
$str.="</select>
</div>
<div align='right' style='margin-right:17px;'>
<img src=".IMAGES."search_button.jpg border='0' alt=''/>
</div>
</div>";
/* return $str;
} */
?>
Now we create two more function in app_controller
function callModule($modules)
{
foreach($modules as $moduleName)
{
$moduleList['mod_'.$moduleName]=$this->loadModule($moduleName);
}
$this->setter($moduleList);
}
function loadModule($module)
{
if($_SERVER['HTTP_HOST']="192.168.5.30")
$path=$_SERVER['DOCUMENT_ROOT']."/newtopn/app/modules/";
else
$path=$_SERVER['DOCUMENT_ROOT']."/app/modules/";
// if mod_$mod1 is active in database then call otherwise retrun
blank
require_once($path. "mod_".$module.".php");
// $execute_module="mod_".$module;
return $str;
}
function common_arrays($opt='')
{
$this-
>abcd=array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
$this-
>education=array('MBA'=>"MBA",'MCA'=>"MCA",'LLB'=>"LLB",'M.TECH'=>"M.TECH");
$this-
>days=array('Monday'=>'Monday','Tuesday'=>'Tuesday','Wednesday'=>'Wednesday','Thursday'=>'Thursday','Saturday'=>'Saturday','Sunday'=>'Sunday');
$this->firm_size=array(1=>'less than 100',2=>'100-200',3=>'200-300',
4=>'400-500',5=>'above 500');
$this-
>language=array('English'=>'English','Chinese'=>'Chinese','Spanish'=>'Spanish','Other'=>'Other');
$this-
>timing=array('12'=>'12','11'=>'11','10'=>'10','9'=>'9','8'=>'8','7'=>'7','6'=>'6','5'=>'5','4'=>'4','3'=>'3','2'=>'2','1'=>'1',);
$this-
>pricing=array("Fixed"=>"Fixed","Bid"=>"Bid","Hourly"=>"Hourly");
$this->litigation =array("Plaintiff"=>"Plaintiff","Defense
"=>"Defense ","Both"=>"Both");
$this->experience=array(1=>'less than 5 yrs',2=>'5-10 yrs',
3=>'10-15 yrs',4=>'15-20 yrs',5=>'above 20 yrs');
$this->month =
array('1'=>'Jan','2'=>'Feb','3'=>'Mar','4'=>'Apr','5'=>'May','6'=>'Jun','7'=>'Jul','8'=>'Aug','9'=>'Sep','10'=>'Oct','11'=>'Nov','12'=>'Dec');
$this->months =
array('01'=>'Jan','02'=>'Feb','03'=>'Mar','04'=>'Apr','05'=>'May','06'=>'Jun','07'=>'Jul','08'=>'Aug','09'=>'Sep','10'=>'Oct','11'=>'Nov','12'=>'Dec');
$this->year =
array('2007'=>'2007','2008'=>'2008','2009'=>'2009','2010'=>'2010','2011'=>'2011','2012'=>'2012');
}
function make_array($data)
{
$i=0;
foreach($data as $index=>$row)
{
foreach($row as $index1=>$row1)
{
foreach($row1 as $index2=>$row2)
{
$array[$i][$index2]=$row2;
}
}
$i++;
}
return @$array;
}
Now from any controller :
add two lines in your function:
$callModule=array('modulename', 'modulename', ....);
$this->callModule($callModule);
Rahul - this group is not for general CakePHP discussion - please
repost this in http://groups.google.com/group/cake-php/
Felix, correct me if I am wrong - else - I guess the guidelines need
to be a bit more explicit in these regards.
BTW, see http://www.ad7six.com/MiBlog/MiniControllers by the Awesome Andy :)
Tarique
--
=============================================================
Cheesecake-Photoblog: http://cheesecake-photoblog.org
PHP for E-Biz: http://sanisoft.com
=============================================================
Felix, correct me if I am wrong - else - I guess the guidelines need to be a bit more explicit in these regards.
AIM: | theundefined87 |
---|---|
Skype: | TimeFor23 |
Other IM: | felixge.de |
Mobile (USA): | +1 404 3888693 |
Mobile (GER): | +49 162 9391612 |
Twitter: | http://twitter.com/felixge |