How to make Drupal 7 Editable field in table for admin only(如何使 Drupal 7 可编辑字段在表中仅供管理员使用)
问题描述
$header = array(
array('data' => t('S No'), 'field' => 't.id'),
array('data' => t('Country Name'), 'field' => 't.country_name'),
array('data' => t('Status'), 'field' => 't.status'),
array('data' => t('Added Date'), 'field' => 't.added_date'),
array('data' => t('Action'), 'field' => 't.id',),
array('data' => t('Action'), '',),
);
$limit = 10;
$query = db_select('countries', 't')->extend('TableSort')->extend('PagerDefault')->limit($limit)->orderby('country_name', ASC);
//condition();
$query->fields('t');
//$edit=echo '<i class="fa fa-pencil-square-o"></i>';
//$edit=echo '<i class="fa fa-pencil-square-o"></i>';
// Don't forget to tell the query object how to find the header information.
$result = $query
->orderByHeader($header)
->execute();
$rows = array();
$i=1;
foreach ($result as $row) {
$rows[] = array(
$i,
//($x === 2) ? 0 : $x+1,
//$row->id,
$row->country_name,
//$row->status,
//$row->status,
$status = ($row->status == 0) ? 'Inactive' : 'Active',
date('d-m-Y H:i:s', strtotime($row->added_date)),
l('Edit', 'mypages/countries/'. $row->id),
l('Delete', 'mypages/delete/'. $row->country_name)
);
//print_r($status);
$i++;
}
In this data where i am getting data from database and displaying it ..Now i want display the status as dynamic like admin can modify the status if he requires..
$status = ($row->status == 0) ? 'Inactive' : 'Active',
Where he can make active or inactive
if we can give active or inactive in drop down its better ..where admin can select the status..after that automatically update to selected status... and I am displaying S no as numbering which is ..the numbers working in first page like numbering auto increment where numbering to second page ..the numbering system is starting from the initial again...
What is the solutions for above
You may have to create another header item to perform the activation/deactivation action, By checking the user_access. In the rows you can add links to whether activate/deactivate depending on the current status. You can redirect to the edit page on clicking the activate or deactivate links by passing query parameters, status and update the status.
这篇关于如何使 Drupal 7 可编辑字段在表中仅供管理员使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使 Drupal 7 可编辑字段在表中仅供管理员使用
基础教程推荐
- 在多维数组中查找最大值 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- 超薄框架REST服务两次获得输出 2022-01-01