如何在表中为Drupal 7 Editable字段创建仅限admin

时间:2022-06-04 06:30:01
 $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...

如果我们可以提供活动或非活动下拉其更好..管理员可以选择状态..之后自动更新到选定状态...我显示S否编号,这是...在第一页工作的数字喜欢编号自动增量编号到第二页...编号系统从最初开始再次...

What is the solutions for above

上面有什么解决方案

1 个解决方案

#1


0  

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.

您可能必须创建另一个标题项来执行激活/停用操作,方法是检查user_access。在行中,您可以添加指向是否激活/取消激活的链接,具体取决于当前状态。您可以通过传递查询参数,状态和更新状态,在单击激活或取消激活链接时重定向到编辑页面。

#1


0  

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.

您可能必须创建另一个标题项来执行激活/停用操作,方法是检查user_access。在行中,您可以添加指向是否激活/取消激活的链接,具体取决于当前状态。您可以通过传递查询参数,状态和更新状态,在单击激活或取消激活链接时重定向到编辑页面。