View
module -> phpfox_sample ->
Template -> Default -> Controller
userdisplay.html.php
<form name="form2"
method="post" action="{url
link='product.userdisplay'}"
enctype="multipart/form-data">
Name : <select
name="val[user_id]">
<option value="0">select
</option>
{foreach from=$userdetails
name=userdetail item=detailName}
<option
value="{$detailName.u_id}">{$detailName.name} </option>
{/foreach}
</select>
<input type="submit"
name="val[submit]" > </br>
</form>
<table style="border: 1px solid
#0088CC; width: 500px; ">
{foreach from=$details name=detail
item=detailValue}
<tr style="border: 1px
solid #0088CC;">
<td style="border-right:
1px solid #0088CC;">{$detailValue.content}</td>
<td style="border-right:
1px solid #0088CC;">{$detailValue.privacy}</td>
</tr>
{/foreach}
</table>
module -> phpfox_sample ->
Include -> Component -> Controller
userdisplay.class.php
class
Product_Component_Controller_Userdisplay extends Phpfox_Component
{
$userdetails =
Phpfox::getService('product.userdisplayservice')->getUser();
if($userdetails)
$this->template()->assign(array('userdetails'=>$userdetails));
public function process()
{
if($aVals =
$this->request()->get('val'))
{
unset($aVals['submit']);
$details =
Phpfox::getService('product.userdisplayservice')->get($aVals);
if($details)
$this->template()->assign(array('details'=>$details));
}
}
}
module -> phpfox_sample ->Include
-> Service
userdisplayservice.class.php
class
Product_Service_Userdisplayservice extends Phpfox_Service
{
/**
*Function to get rows from table
* @return type
* @author Arun George
<arun@arun-g.in>
* @since 20-11-2012
*/
function getUser()
{
$uname =
$this->database()->select('*')
->from(Phpfox::getT('newuser'))
->execute('getSlaveRows');
// d($row);
return $uname;
}
/**
*Function to get rows from
table
* @return type
* @author Arun George
<arun@arun-g.in>
* @since 20-11-2012
*/
function get($aVals)
{
// d($aVals);
// exit();
//
$cond = '';
if($aVals['user_id']==1)
{
$cond = ' r.privacy
IN(1,2,3)';
}
elseif($aVals['user_id']==2)
{
$cond = ' r.privacy
IN(1,2)';
}
elseif($aVals['user_id']==3)
{
$cond = ' r.privacy
IN(3)';
}
else{
$cond = ' r.privacy
IN(0)';
}
$row =
$this->database()->select('r.*')
->from(Phpfox::getT('usercontent'), 'r')
->where($cond)
->execute('getRows');
return $row;
}
}
No comments:
Post a Comment