如何让Drupal的7场可编辑在表中仅管理 [英] How to make Drupal 7 Editable field in table for admin only

查看:196
本文介绍了如何让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++;
  }

在此数据在那里我是从数据库中获取数据并显示它..Now我想显示为动态管理一样的状态可以修改状态,如果他需要..

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管理员可以选择自动更新选定状态status..after ...
而我显示没什么作为的编号是在第一页的工作像编号自动递增,其中编号为..the编号系统第二页..the号从初始重新开始...

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...

什么是上述解决方案

推荐答案

您可能必须创建另一个标题项进行激活/停用行动,通过检查user_access。
在行,你可以添加链接是否根据当前状态来启用/停用。您可以重定向到编辑页面上点击激活或者通过查询参数,状态解除链接和更新状态。

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场可编辑在表中仅管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆